6

I'm creating a server and client situation where i want to create a pipe so they can communicate.

I created the pipe in the server code with mkfifo("fifo",1755);:

  • 1 for only user that created and root to be able to delete it or rename it,
  • 7 for give read, write and exec to user, and
  • 5 for both group and other to only give them read and exec.

The problem is that later in the server code I open the fifo to read from it open("fifo",O_RDONLY); but when i execute it, it shows me an perror that denies me acess to the fifo.

I went to see the permissions of the pipe fifo and it says p-wx--s--t so:

  • p stands for pipe,
  • - means the user has no read. I don't know how when I gave it with the 7,
  • s group executes has user. I don't how if i gave 1 so supposedly it should give to user and others the ability to only read and execute and others have t that was expected.

Do I have a misunderstanding of the permissions?

13

You cannot simply exec a binary from a pipe: Is there a way to execute a native binary from a pipe?. Also I don't think the sticky bit on executables is worth anything on modern systems.

I created the pipe in the server code with mkfifo("fifo",1755);

I went to see the permissions of the pipe fifo and it says p-wx--s--t so:

Your error is to have written the 1755 permission without the leading 0, which means that 1755 has been treated as a decimal instead of octal (1755 & ~022 = 03311 = p-wx--s--t; where 022 is your umask)

  • So a better solution would be create a dir and chmod 1755 the dir then create the pipe in that dir with ``` mkfifo ("fifo",755); ``` ? – Joao Parente Apr 11 at 10:19
  • 3
    The sticky bit has different semantics for files and directories: for directories it prevents users from removing or renaming files they don't own; for regular files it doesn't mean much nowadays. Read the chmod(2) manpage for all the details. Also, mkfifo("fifo", 0755) with the leading 0 ;-). – mosvy Apr 11 at 10:24
  • thanks very much :P – Joao Parente Apr 11 at 10:26
  • i tried mkfifo("fifo",0777); but i only got prwxr-xr-xbut if i do chmod 0777 fifo after i created fifo i get prwxrwxrwxany idea why it doesnt work when i create it – Joao Parente Apr 11 at 17:09
  • Because of the umask -- the umask which is 022 will mask out the write permissions from group (020) and other (002) anytime a file is created with open(2), mkfifo(2), etc. Read the umask(2) manpage. The umask doesn't affect the chmod syscall or command. – mosvy Apr 11 at 17:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.