Questions tagged [suid]

Use [suid] only for the suid/nosuid option of mount. Use the more general [setuid] for questions about the setuid/setgid mechanism in Unix.

16 questions
3
votes
1 answer

Why doesn't setuid() work with non-root users?

I'm experiencing a weird behavior regarding setuid() and the setuid bit. It seems like the suid bit and setuid() do not work as expected. I am expecting for a binary with +s and owned by uid 1001 that calls setuid(1001) to be called from any uid…
Tobi Nary
  • 141
  • 7
3
votes
0 answers

How to create a directory behalf on root user?

I have a script: [postgres@LaHarch ~]$ cat mkrundir.sh #!/bin/bash mkdir /run/postresql With attributes: [postgres@LaHarch ~]$ ll mkrundir.sh -rwsr-sr-x 1 root root 74 Aug 26 18:53 mkrundir.sh But when I run it I get: [postgres@LaHarch ~]$…
3
votes
2 answers

What does it mean for a folder to have suid permission?

I know what it means for a file to have suid permission. It means when other users have execute permission for it, they execute as the owner of the file. But what does it imply when a folder has suid permission? I did some testing and it seems…
Just a learner
  • 1,766
  • 4
  • 22
  • 32
2
votes
1 answer

Alternatives to suid, for script and interpreted languages

On Unixes (including Gnu/Linux) suid/sgid (or file capabilities) is the only, native (all other ways use this way), way to escalate privileges. As a sysadmin, I like to write scripts as they are easy, and well adated to the task. However suid and…
ctrl-alt-delor
  • 27,473
  • 9
  • 58
  • 102
1
vote
2 answers

SUID bit ignored when creating files / directories

I've set the SUID & SGID bit on a folder belonging to user foo with sudo chmod g+s myfolder & sudo chmod u+s myfolder drwsr-sr-x 24 foo www-data 4,0K Okt 25 16:17 myfolder Then I went inside and created a folder with sudo mkdir xyz, but the user of…
Black
  • 1,989
  • 7
  • 28
  • 58
1
vote
1 answer

does nosuid work on bind-mounts to suid partitions?

if i have /target mounted with suid and then make a bind-mount on /bound with mount -o bind,nosuid /target /bound, will nosuid take effect on /bound ? (imo it should take effect but i'd still like a definite answer, and nobody else had asked yet…
hanshenrik
  • 585
  • 4
  • 20
1
vote
0 answers

Need to run scripts/commands with root privileges for user selfservices

The core of the topic is a very a common but I am not satisfied. I have a script looking for a pid and running the kill command on the pid if found. So I chown the script to root.root and add 4755 as suid. The script should now run with root…
Jan S
  • 57
  • 6
0
votes
1 answer

how to allow running a suid exe only with restricted params/env/context?

I have a suid-to-root executable that users should run only with certain parameters, env var settings and context setup. I can't modify that exe. I will wrap the exe in arg-less scripts, one for each allowed parameterization, env and context setup.…
schmeg
  • 21
  • 1
0
votes
1 answer

Why does adding a user and setting an SUID for it throws me the "Operation not permitted" error?

I am setting SUID for a new user tommy to run the same commands as root but it goes down like this: [root@192 ~]# useradd tommy [root@192 ~]# su - tommy [tommy@192 ~]$ chmod u+s /usr/bin/ls chmod: changing permissions of '/usr/bin/ls': Operation not…
sengh
  • 1
0
votes
1 answer

Escalated predefined ssh scripts to remote computer implemetation

The problem is that I want to run certain ssh commands (Or scripts) from computerA to computerB without using a password. Examples: ssh apple@computerB 'poweroff' ssh apple@computerB "killall firefox; systemctl enable apache; firefox" ssh…
Saft
  • 36
  • 4
0
votes
1 answer

How can I verify that a file is being execute as root account?

Let's say we have created a file with root account with -rwsr-xr-x script.sh permissions. We have set suid bit on this file so any user who is gonna execute this file, it's gonna be execute by owner of the file which is root. For example let's look…
Mohammad
  • 1
  • 1
0
votes
1 answer

Any reason for specifying -type f in find when looking for files with SUID bit set?

What's the reason for using -type f with find / -perm -u=s -type f 2>/dev/null. I see this all over the Internet and don't understand why to specify the type as regular file if look for SUID bit set. SUID can be set only of files and not…
user211245
  • 27
  • 1
  • 2
0
votes
1 answer

Common binaries with support for command execution, like `awk` and `vim`, not respecting setuid bit?

I'm hardening a Linux system and wanted to test (setuid-based) shell escapes using common binaries, like awk, vim, etc., supporting command executing. However, all binaries I've tested except sh and bash don't respect their setuid bit. In…
Shuzheng
  • 4,023
  • 1
  • 31
  • 71
0
votes
0 answers

Run a script as root with SUID

I created a simple script on Ubuntu Server 18.04: #!/bin/bash apt update apt upgrade then I changed the owner to root # chown root update.sh then I added SUID bit and execution bits for user and group # chmod u+xs,g+x update.sh and this is what I…
Sasan
  • 143
  • 5
0
votes
1 answer

How to Run the command or script through any user in linux?

I am having a C executable in AIX system by which I can run the command through any user like root or system users. script having below permissions. On AIX server lrwsrwxrwx 1 root system 24 Mar 2016 /var/srty/bin/switchuseridprogram ->…
user3548033
  • 593
  • 2
  • 12
  • 25
1
2