By Joao Parente


2019-04-11 10:01:33 8 Comments

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?

1 comments

@mosvy 2019-04-11 10:18:09

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)

@Joao Parente 2019-04-11 10:19:54

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); ``` ?

@mosvy 2019-04-11 10:24:31

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 ;-).

@Joao Parente 2019-04-11 10:26:43

thanks very much :P

@Joao Parente 2019-04-11 17:09:07

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

@mosvy 2019-04-11 17:15:42

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.

Related Questions

Sponsored Content

7 Answered Questions

[SOLVED] Execute vs Read bit. How do directory permissions in Linux work?

1 Answered Questions

[SOLVED] Permissions Based on Lowest Level

  • 2018-08-04 20:59:08
  • Sam Jaques
  • 38 View
  • 0 Score
  • 1 Answer
  • Tags:   permissions chmod

1 Answered Questions

[SOLVED] Mounting volume/partition with permissions for user

  • 2018-07-12 18:53:35
  • adatum
  • 3218 View
  • 1 Score
  • 1 Answer
  • Tags:   permissions mount

5 Answered Questions

[SOLVED] How do file permissions work for the "root" user?

2 Answered Questions

[SOLVED] Why can't I list a directory with read permissions?

2 Answered Questions

[SOLVED] Give full permissions to the owner and only one other user

1 Answered Questions

1 Answered Questions

[SOLVED] Not allowed to read a file with correct group permissions? ACL?

  • 2014-03-13 16:00:55
  • Diti
  • 1260 View
  • 2 Score
  • 1 Answer
  • Tags:   permissions acl

0 Answered Questions

vsftpd virtual user read permissions

Sponsored Content