Re: What do these file permissions mean ---Sr-x--T ?



jc@xxxxxxxxxxx wrote:
I figured out the culprit: it was the open() call in the application.
I was using the open() function without the mode parameter even though I was
specifying O_CREAT flag.

Which form of open() did you use?

int open(const char *pathname, int flags);
int open(const char *pathname, int flags, mode_t mode);

According to man 2 open:

mode must be specified when O_CREAT is in the flags, and is ignored otherwise.

Since you specify above that you used O_CREAT you must use the second form of open(), including the "mode", which is what sets permissions on the filesystem level.

*IF* you used the first form of open(), e.g. with out the "mode" parameter, I would assume (ALL caveats apply!) the system is expecting the "mode" to be passed on the stack as the third parameter, which it isn't getting, so it will use whatever 32-bits happen to be in that position on the stack. Under other circumstances you will get a file with different, bizarre, permissions, based on that stack contents.

So, it seems that when one does such an atrocity, the OS (or filesystem?)
decides to use the bizarre permissions (---Sr-x--T) on newly created files.

Read the man page, check your code. I'll bet 1 glazed Krispy Kreme donut you used the first form of open(), when the second form is required because of the O_CREAT flag.
.



Relevant Pages

  • [PATCH] riscom8: Coding style
    ... unsigned long flags; ... unsigned char val1, val2; ... struct riscom_port *port; ...
    (Linux-Kernel)
  • perfmon3 interface overview
    ... words redesign of the perfmon2 syscall API. ... Each syscall has a flags parameters which allows the syscalls to be ... int pfm_create_session; ... It is located in the perfmon3 branch. ...
    (Linux-Kernel)
  • [PATCH 03/18] flag parameters: paccept
    ... This syscall differs from accept in that it adds ... The flags parameter can be used to set flag like SOCK_CLOEXEC. ... we really want the signal mask ... handler (int s) ...
    (Linux-Kernel)
  • [PATCH 02/18] flag parameters: paccept
    ... This syscall differs from accept in that it adds ... The flags parameter can be used to set flag like SOCK_CLOEXEC. ... we really want the signal mask ... handler (int s) ...
    (Linux-Kernel)
  • [PATCH] esp: Clean up to modern coding style
    ... set_serial_info fixed to set the flags, custom divisor, and uart ... +static void program_isa_dma(int dma, int dir, unsigned long addr, int len) ... This routine will shutdown a serial port; ...
    (Linux-Kernel)