After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 345244 - gamin does not work for SUID binaries
gamin does not work for SUID binaries
Status: RESOLVED WONTFIX
Product: gamin
Classification: Other
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Gamin Maintainer(s)
Gamin Maintainer(s)
gnome[unmaintained]
Depends on:
Blocks:
 
 
Reported: 2006-06-18 14:05 UTC by Isak Savo
Modified: 2018-07-01 08:48 UTC
See Also:
GNOME target: ---
GNOME version: 2.13/2.14


Attachments
Test case that exposes the problem (2.46 KB, text/plain)
2006-06-18 14:08 UTC, Isak Savo
  Details
Fix euid!=ruid problem and portability (for Solaris getpeerucred(3C)) (5.22 KB, patch)
2008-07-30 06:16 UTC, SATOH Fumiyasu
none Details | Review
gam_server: Drop privileges after fork if euid != ruid (1.14 KB, patch)
2009-02-09 15:19 UTC, SATOH Fumiyasu
none Details | Review
gam_server: Use geteuid(2) instead of getuid(2) to check own privilege (2.27 KB, patch)
2009-02-09 15:21 UTC, SATOH Fumiyasu
none Details | Review

Description Isak Savo 2006-06-18 14:05:09 UTC
If you have a binary that has its SUID bit set, it cannot monitor files using gamin (haven't tried if original FAM supports this, perhaps not).

I've written a small test program that opens a fam connection and monitors the file passed as argv[1]. If the program is SUID root (i.e. chmod root:root famtest && chmod +s famtest), and is executed by a non-root user, it will shut down because gamin closes the socket (HUP received in the GIOChannel watch).

If the program does 
   setuid(geteuid());
then everything works as expected. 

This is gamin 1.1.7 on Ubuntu Dapper.

Let me know if you need debugging output from gamin (I thing you'll be able to reproduce it using the attached test program)
Comment 1 Isak Savo 2006-06-18 14:08:39 UTC
Created attachment 67576 [details]
Test case that exposes the problem

Compile with:
gcc famtest.c `pkg-config glib-2.0 --libs --cflags` -lfam -Wall -g -o famtest
Then change its permissions to SUID root.
Then run it as a normal user.

(Uncomment line 26 and 27 to see that it works if uid==euid)
Comment 2 SATOH Fumiyasu 2008-07-30 06:16:58 UTC
Created attachment 115542 [details] [review]
Fix euid!=ruid problem and portability (for Solaris getpeerucred(3C))

This is a gamin euid patch:                                                               

  * Samba (effective uid is user's uid, but real uid is 0):
    + Use geteuid(2) instead of getuid(2) to check own privilege
    + gam_server: Drop privileges after fork if euid != ruid
  * Solaris: Use getpeerucred() to get peer's credentials
Comment 3 SATOH Fumiyasu 2009-02-09 15:19:26 UTC
Created attachment 128300 [details] [review]
gam_server: Drop privileges after fork if euid != ruid

gam_server: Drop privileges after fork if euid != ruid for
Samba and setuid commands support (effective uid is user's uid, but real uid is 0).
Comment 4 SATOH Fumiyasu 2009-02-09 15:21:32 UTC
Created attachment 128301 [details] [review]
gam_server: Use geteuid(2) instead of getuid(2) to check own privilege

Use geteuid(2) instead of getuid(2) to check own privilege
for Samba support (effective uid is user's uid, but real uid is 0).
Comment 5 André Klapper 2018-07-01 08:48:08 UTC
gamin is not under active development anymore and has not seen code changes for many years.
Its codebase has been archived: https://gitlab.gnome.org/Archive/gamin/commits/master

Closing this report as WONTFIX as part of Bugzilla Housekeeping to reflect reality. Please feel free to reopen this ticket (or rather transfer the project to GNOME Gitlab, as GNOME Bugzilla is deprecated) if anyone takes the responsibility for active development again.