only drop privileges if running as root
PATCH 1/1 only drop privileges if running as root
only drop privileges if running as root
Hi Kay, this simple patch fixes problems like this
[davidz@zelda ~]$ ls -l /dev/scd0
brw-rw----+ 1 davidz disk 11, 0 2007-06-06 10:46 /dev/scd0
[davidz@zelda ~]$ /lib/udev/vol_id /dev/scd0
error dropping privileges: Operation not permitted
[davidz@zelda ~]$ sudo /lib/udev/vol_id /dev/scd0
ID_FS_USAGE=filesystem
ID_FS_TYPE=udf
ID_FS_VERSION ID_FS_UUID ID_FS_LABEL=LOST_S1_DISC2_US
ID_FS_LABEL_SAFE=LOST_S1_DISC2_USwhere vol_id refuses to probe the device despite the fact that the calling user have access to it. Please apply.
extras/volume_id/vol_id.c +15 -13
@@ -236,19 +236,21 @@ int main(int argc, char *argv[]) size =0 ;dbg ("BLKGETSIZE64=%llu" , (unsigned long long )size); -/* try to drop all privileges before reading disk content */ - pw =getpwnam ("nobody" ); -if (pw !=NULL && pw->pw_uid >0 && pw->pw_gid >0 ) { -dbg ("dropping privileges to %u:%u" , - (unsigned int )pw->pw_uid, (unsigned int )pw->pw_gid); -if (setgroups (0 ,NULL ) !=0 || -setgid (pw->pw_gid) !=0 || -setuid (pw->pw_uid) !=0 ) { -fprintf (stderr,"error dropping privileges: %s\n" ,strerror (errno)); - rc =3 ; - goto exit; - } - } +/* if we're uid 0, try to drop all privileges before reading disk content */ +if (getuid () =0 ) { + pw =getpwnam ("nobody" ); +if (pw !=NULL && pw->pw_uid >0 && pw->pw_gid >0 ) { +dbg ("dropping privileges to %u:%u" , + (unsigned int )pw->pw_uid, (unsigned int )pw->pw_gid); +if (setgroups (0 ,NULL ) !=0 || +setgid (pw->pw_gid) !=0 || +setuid (pw->pw_uid) !=0 ) { +fprintf (stderr,"error dropping privileges: %s\n" ,strerror (errno)); + rc =3 ; + goto exit; + } + } + }if (probe_all) {volume_id_all_probers (all_probers, vid,0 , size,NULL );
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Kay Sievers
AppliedQuoted 1 line · David Zeuthen
only drop privileges if running as root
Applied.
Thanks,
Kay
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel