setuid

Change UID/GID only of one thread in Linux

谁都会走 提交于 2019-12-01 17:32:54
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 usually fork() themselves at the beginning and process each user request in separate process. If there is a need for shared data, it must go through some kind of shared memory. However, e.g. the FUSE (linux user filesystem) by default uses multithreading and in

Why do my setuid root bash shell scripts not work?

非 Y 不嫁゛ 提交于 2019-11-30 17:27:59
问题 I created this simple script to allow the user to remove files created by the web server in his home directory without giving him "su". Both scripts are set with "chmod 4750". The craziest thing is that they DID work and now they don't. Here's the scripts: #!/bin/bash # Ask for directory to delete echo "Enter the file or directory you would like to delete, the assumed path is /home/user" read DIRECTORY rm -rf /home/user/"$DIRECTORY" echo "Deleting /home/user/$DIRECTORY ..." exit 0 2: #!/bin

How to successfully run Perl script with setuid() when used as cgi-bin?

浪子不回头ぞ 提交于 2019-11-29 11:40:41
I have a Perl script that is called either via Apache or on the command-line. For testing purposes, I pass it the username I want the Perl script to operate with, and use POSIX::setuid to set the uid . If I run the script from the command line, then the uid is set properly: use CGI::Pretty qw/:standard/; use POSIX qw(setuid getuid); ... my ($pwName, $pwCode, $pwUid, $pwGid, $pwQuota, $pwComment, $pwGcos, $pwHome, $pwLogprog) = getpwnam($username); if ((defined $pwUid) && (getuid() == $pwUid)) { setuid($pwUid); print header; print Dumper $<; } else { print header(-status => 401); print "Could

LD_PRELOAD with setuid binary

馋奶兔 提交于 2019-11-29 06:47:33
I am trying to use LD_PRELOAD to preload a library with an application that has setuid permissions. Tried LD_PRELOAD at first, and it seemed like it was being ignored with the setuid binary, though it was working when I tried it with others like ls , dir etc. From the documentation of LD_PRELOAD: LD_PRELOAD A whitespace-separated list of additional, user-specified, ELF shared libraries to be loaded before all others. This can be used to selectively override functions in other shared libraries. For set- user-ID/set-group-ID ELF binaries, only libraries in the standard search directories that

Getting message “sudo: must be setuid root”, but sudo IS already owned by root [closed]

孤人 提交于 2019-11-28 17:19:00
I'm trying to run sudo, and it's failing: gregd@david $ sudo ls sudo: must be setuid root gregd@david $ which sudo /usr/bin/sudo gregd@david $ ll /usr/bin/sudo -rwxr-xr-x 1 root root 165K 2012-05-16 00:25 /usr/bin/sudo* Any suggestions on how to fix this? Adam This problem is caused sometimes when the permissions of the file, /usr/bin/sudo get set to 777. If you do something like chmod -R 777 /usr/ , you can do this. It effectively ruins sudo. Here is the solution if this is your problem, and the accepted answer doesn't work: To fix: Restart pc, press shift at boot menu. This should bring up

RealUID, Saved UID, Effective UID. What's going on?

柔情痞子 提交于 2019-11-28 15:23:31
This is a set-root-uid program $ls -l -rwsr-sr-x 1 root root 7406 2011-12-13 22:37 ./x* The source code: int main(void) { printf( " UID GID \n" "Real %d Real %d \n" "Effective %d Effective %d \n", getuid (), getgid (), geteuid(), getegid() ); seteuid(600); printf( " UID GID \n" "Real %d Real %d \n" "Effective %d Effective %d \n", getuid (), getgid (), geteuid(), getegid() ); setuid(1000); printf( " UID GID \n" "Real %d Real %d \n" "Effective %d Effective %d \n", getuid (), getgid (), geteuid(), getegid() ); setuid(0); // HOW DOES THIS SUCCEED IN SETTING THE EUID BACK TO 0 printf( " UID GID \n"

How to successfully run Perl script with setuid() when used as cgi-bin?

别来无恙 提交于 2019-11-28 05:23:45
问题 I have a Perl script that is called either via Apache or on the command-line. For testing purposes, I pass it the username I want the Perl script to operate with, and use POSIX::setuid to set the uid . If I run the script from the command line, then the uid is set properly: use CGI::Pretty qw/:standard/; use POSIX qw(setuid getuid); ... my ($pwName, $pwCode, $pwUid, $pwGid, $pwQuota, $pwComment, $pwGcos, $pwHome, $pwLogprog) = getpwnam($username); if ((defined $pwUid) && (getuid() == $pwUid))

LD_PRELOAD with setuid binary

本秂侑毒 提交于 2019-11-28 00:09:11
问题 I am trying to use LD_PRELOAD to preload a library with an application that has setuid permissions. Tried LD_PRELOAD at first, and it seemed like it was being ignored with the setuid binary, though it was working when I tried it with others like ls , dir etc. From the documentation of LD_PRELOAD: LD_PRELOAD A whitespace-separated list of additional, user-specified, ELF shared libraries to be loaded before all others. This can be used to selectively override functions in other shared libraries

Setuid bit on python script : Linux vs Solaris

空扰寡人 提交于 2019-11-27 22:58:40
I am running this small python script on both linux and Solaris as a not privileged user : #!/usr/bin/python import os print 'uid,euid =',os.getuid(),os.geteuid() Before running, the setuid bit is set on the script (not on python interpreter) : chown root:myusergrp getuid.py chmod 4750 getuid.py On Solaris, the effective uid is set because of the setuid bit : uid,euid = 10002 0 But not on Linux : uid,euid = 10002 10002 Note the python version is 2.6 for both Solaris and Linux Is it possibe to have Python Linux working as Python Solaris ? Most Unix distributions normally don't allow you to use

Getting message “sudo: must be setuid root”, but sudo IS already owned by root [closed]

旧街凉风 提交于 2019-11-27 10:35:35
问题 I'm trying to run sudo, and it's failing: gregd@david $ sudo ls sudo: must be setuid root gregd@david $ which sudo /usr/bin/sudo gregd@david $ ll /usr/bin/sudo -rwxr-xr-x 1 root root 165K 2012-05-16 00:25 /usr/bin/sudo* Any suggestions on how to fix this? 回答1: This problem is caused sometimes when the permissions of the file, /usr/bin/sudo get set to 777. If you do something like chmod -R 777 /usr/ , you can do this. It effectively ruins sudo. Here is the solution if this is your problem, and