mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-13 17:26:34 +00:00
Better setgid by Christopher
git-svn-id: https://svn.fhem.de/fhem/trunk@1204 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
1952f29a97
commit
cf5fd30fa1
@ -3,8 +3,8 @@
|
|||||||
- feature: the usb command tries to flash unflashed CULs on linux
|
- feature: the usb command tries to flash unflashed CULs on linux
|
||||||
- feature: FHEMWEB: jsonp support, .holiday and .cfg added to Edit Files
|
- feature: FHEMWEB: jsonp support, .holiday and .cfg added to Edit Files
|
||||||
- feature: SVG: filled area support, some ls/lw fixes
|
- feature: SVG: filled area support, some ls/lw fixes
|
||||||
- feature: WOL (wake on lan) module added
|
- feature: WOL (wake on lan) module added (by Matthias)
|
||||||
|
- feature: additional groups from /etc/groups are applied (Christopher)
|
||||||
|
|
||||||
- 2011-12-31 (5.2)
|
- 2011-12-31 (5.2)
|
||||||
- bugfix: applying smallscreen attributes to firefox/opera
|
- bugfix: applying smallscreen attributes to firefox/opera
|
||||||
|
26
fhem/fhem.pl
26
fhem/fhem.pl
@ -253,17 +253,29 @@ if(int(@ARGV) != 1 && int(@ARGV) != 2) {
|
|||||||
# If started as root, and there is a fhem user in the /etc/passwd, su to it
|
# If started as root, and there is a fhem user in the /etc/passwd, su to it
|
||||||
if($^O !~ m/Win/ && $< == 0) {
|
if($^O !~ m/Win/ && $< == 0) {
|
||||||
|
|
||||||
my @gr = getgrnam("dialout");
|
|
||||||
if(@gr) {
|
|
||||||
use POSIX qw(setgid);
|
|
||||||
setgid($gr[2]);
|
|
||||||
}
|
|
||||||
|
|
||||||
my @pw = getpwnam("fhem");
|
my @pw = getpwnam("fhem");
|
||||||
if(@pw) {
|
if(@pw) {
|
||||||
use POSIX qw(setuid);
|
use POSIX qw(setuid setgid);
|
||||||
|
|
||||||
|
# set primary group
|
||||||
|
setgid($pw[3]);
|
||||||
|
|
||||||
|
# read all secondary groups into an array:
|
||||||
|
my @groups;
|
||||||
|
while ( my ($name, $pw, $gid, $members) = getgrent() ) {
|
||||||
|
push(@groups, $gid) if ( grep($_ eq $pw[0],split(/\s+/,$members)) );
|
||||||
|
}
|
||||||
|
|
||||||
|
# set the secondary groups via $)
|
||||||
|
if (@groups) {
|
||||||
|
$) = "$pw[3] ".join(" ",@groups);
|
||||||
|
} else {
|
||||||
|
$) = "$pw[3] $pw[3]";
|
||||||
|
}
|
||||||
|
|
||||||
setuid($pw[2]);
|
setuid($pw[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
###################################################
|
###################################################
|
||||||
|
Loading…
x
Reference in New Issue
Block a user