Skip to content

Write CIFS file 'permission denied' (Linux) #42790

@tai-yi

Description

@tai-yi

Dear guys,

I got an error when I use my application write to a CIFS file folder mounted on host machine.

I tried use same user with shell script echo 123 > /mnt/debug/a.txt success.

After application error, there is a 0kb file in the folder, means the file is created but application cannot flush binary content into the file.

Mount options mount -t cifs --verbose -o domain=***,username=***,password='***',dir_mode=0777,file_mode=0777,noperm,rw \ //somehost/folder /mnt

error log

Unhandled exception. System.UnauthorizedAccessException: Access to the path '/mnt/debug/5d256383-48b6-49f3-99b7-d964c4a964f6' is denied.
 ---> System.IO.IOException: Permission denied
   --- End of inner exception stack trace ---
   at System.IO.FileStream.WriteNative(ReadOnlySpan`1 source)
   at System.IO.FileStream.FlushWriteBuffer()
   at System.IO.FileStream.FlushInternalBuffer()
   at System.IO.FileStream.Flush(Boolean flushToDisk)
   at System.IO.FileStream.Flush()
   at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
   at System.IO.StreamWriter.Dispose(Boolean disposing)
   at System.IO.TextWriter.Dispose()
   at System.IO.File.WriteAllText(String path, String contents)
   at NasDebugger.Program.Main(String[] args)
Aborted (core dumped)

sample code

static int Main(string[] args)
        {
            if (args.Length == 0 || string.IsNullOrEmpty(args[0]))
            {
                Console.WriteLine("please set dir");
                return -1;
            }
            var dir = args[0];
            if (!Directory.Exists(dir))
            {
                Console.WriteLine("please set right dir");
                return -1;
            }
            var id = Guid.NewGuid().ToString();
            File.WriteAllText(Path.Combine(dir, id), "123123");
            Console.WriteLine(id);
            return 0;
        }

Right now , I only can reproduce it in my datacenter😭.

OS Linux version 4.12.14-95.54-default (geeko@buildhost) (gcc version 4.8.5 (SUSE Linux) ) #1 SMP Thu Jun 4 12:49:28 UTC 2020 (892ef1f)
dotnetcore version: 3.1.8

Does anyone have idea about it?

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions