setuid

Can an iPhone App Be Run as Root?

I am thinking about the design of an iPhone app I'd like to create. One possible problem is that this application will have to run as root (to access certain network ports). In a typical UNIX app, I'd just get the app to run with setuid, but I'm wondering if that is possible with an iPhone app. I've read this question in Apple's forum...

Secure access to files in a directory identified by an environment variable?

Can anyone point to some code that deals with the security of files access via a path specified (in part) by an environment variable, specifically for Unix and its variants, but Windows solutions are also of interest? This is a big long question - I'm not sure how well it fits the SO paradigm. Consider this scenario: Background: Sof...

What's the best way to perform system tasks from Ruby on Rails?

I am building a small system administration web application (think Web-Min, but in RoR) and I need to be able to access system parameters from my Ruby code. For instance, I want to allow the user to change the hostname, time zone, or network config of the server. My current thoughts are to have a separate setuid script (Perl, Ruby, ?...

Calling a script from a setuid root C program - script does not run as root.

I need to run a bash script as root (passwordless sudo or su not viable) and since you cannot setuid a script in Linux, I thought about calling it from an executable and making it setuid: $ cat wrapper.c int main(void) { system("/bin/bash ./should_run_as_root.sh"); } $ gcc -o wrapper wrapper.c $ sudo chown root wrapper $ sudo ch...

How do I preserve the setuid bit in tar archives with Perl's Archive::Tar?

I'm using Perl's Archive::Tar module. It preserves the file permissions but doesn't preserve the sticky bit. At the other end where I extract the archive, all the sticky bits are gone. I think UNIX/LINUX operating system stores these sticky bits somewhere else. How can I make my archive preserve sticky bits also? Using the -p switch to ...

Does any Unix-like system ascribe meaning to the SUID bit on a directory?

As the title says, does any Unix-like system ascribe a meaning to the SUID bit on a directory, and if so, what does it mean? The SVTX (saved text, or sticky) bit has a meaning - thou shalt not delete a file from this directory unless you can write to the file. It is used on /tmp, for example. The SGID (set GID) bit has a meaning - fil...

Running upstart jobs as unprivileged users

What's the canonical way to have an upstart job change its userid and run the script as an unprivileged user? Obviously one can use su or sudo, but this seems hacky (and can generate needless log lines). ...

Does anyone use BetterAuthorizationSample?

On OS X privileged operations are done through AuthorizationExecuteWithPrivileges() around which Apple published two recommendations: The old MoreAuth using setuid helper tools. The current BetterAuthorizationSample littering the system with launchd files. I don't know any applications using the latter... ...

Why do I need setuid(0) within a setuid-root C program that calls an administrative program with system()?

I had to do a dirty Linux hack for somebody so they could start a printer with the cupsenable printername shell command while being a non-root user. I didn't want them to be able to use the entirety of the cupsenable syntax as root, so I just wrote a C wrapper that sanitizes the input in argv[1] and calls system("cupsenable sanitizedprin...

Change UID/GID only of one thread in Linux

Is there a way to change UID/GID only of one thread in a multithreaded process? The reason for this is writing a file-serving application - the ACL's and quota are not enforced unless the uid/gid of the caller is set to the correct user, new files/directories are not created with correct uid/gid etc. The network applications can usual...

Program can't load after setting the setuid bit on

Consider this scenario in which an executable A.bin uses libY.so and libZ.so. A.c, Y.c and Z.c are all written in C. Z.c and Y.c are compiled into respective .so files. This is the directory structure of the files $home/bin/A.bin $home/lib/libY.so $home/lib/libZ.so When I run A.bin as normal user, A.bin runs normally as expected. Note...

running git 'post-receive' hook with setuid fails

I have a git repository that needs to run a post-receive hook as sudo. The binary that I compiled to test this looks like: #include <stdlib.h> #include <unistd.h> #include <stdio.h> int main() { int ret; ret = setuid(geteuid()); if(!ret) { fprintf(stderr, "error setting uid %d \n", ret); } system("[...comma...

linux id and setuid/setgid

Is there a simple way to see the real,effective and saved UID and GID for a running process? ...

linux id no_squash_root

The linux 'id' command reports on groups= that process belongs to. When and how does this get filled in? I'm writing an suid/sgid program and it seems that the groups never get filled in for my process and perhaps just coincidentially, but the permissions inregards to an nfs mounted file system don't work correctly for it either (by th...

What's the proper way to drop to a lower privilege level with setuid?

I'm writing a program in C that binds to a port < 1024. I'd like it to run at non-root privileges thereafter. I know I need to call setuid(), but with what argument? UID's vary from system to system. ...

how do i run valgrind to a process which has super user bit on?

I am running valgrind as follows:- /usr/local/bin/valgrind "process_name" After excecution its giving me following error ==21731== ==21731== Warning: Can't execute setuid/setgid executable: ==21731== Possible workaround: remove --trace-children=yes, if in effect ==21731== valgrind: "process name": Permission denied My valgrind per...

Run child processes as different user from a long running process

I've got a long running, daemonized Python process that uses subprocess to spawn new child processes when certain events occur. The long running process is started by a user with super user privileges. I need the child processes it spawns to run as a different user (e.g., "nobody") while retaining the super user privileges for the parent...

Linux group scheduling for user not being applied to setuid-ed process

On the 2.6.28-11 Linux kernel, I am using setpriority to bias the amount of cpu time different user processes receive. User 1 is to receive double the CPU power of user 2. Using Linux's setpriority, I have assigned user 2 a lower priority (higher in terms of nice values). When I run the exact same program via the shell with the computer ...

Git post-receive hook to update a local clone owned by a different user

Hello, I'm trying to set up a git post-receive hook such that when a commit is received, another clone of the repository on the machine gets updated (i.e. does a git pull origin master). I'm using gitosis to serve the repository and as such I believe a post-receive hook will be run as the gitosis user, whereas the repository I want to u...

Check if a file is setuid root in Python

Hi there, I'm trying to check if a file has the setuid bit in Python. The stat doc mentions a S_ISUID function but it only works with os.chmod(), not to actually read the setuid bit. It also lists S_IMODE, but I have no idea how to interpret it. How can I easily check if a file as the setuid root bit set? ...