seatd: Only set UID/GID when specified
The UID/GID defaulted to 0, which results in trying to chown to root when a UID or GID isn't requested. Instead, deafult to -1 so that the unspecified values are left intact.
This commit is contained in:
parent
312d6906ae
commit
c8b3a22d4e
1 changed files with 4 additions and 4 deletions
|
@ -41,11 +41,11 @@ static int open_socket(const char *path, int uid, int gid) {
|
||||||
close(fd);
|
close(fd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (uid != 0 || gid != 0) {
|
if (uid != -1 || gid != -1) {
|
||||||
if (chown(path, uid, gid) == -1) {
|
if (fchown(fd, uid, gid) == -1) {
|
||||||
log_errorf("Could not chown socket to uid %d, gid %d: %s", uid, gid,
|
log_errorf("Could not chown socket to uid %d, gid %d: %s", uid, gid,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
} else if (chmod(path, 0770) == -1) {
|
} else if (fchmod(fd, 0770) == -1) {
|
||||||
log_errorf("Could not chmod socket: %s", strerror(errno));
|
log_errorf("Could not chmod socket: %s", strerror(errno));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ int main(int argc, char *argv[]) {
|
||||||
"\n";
|
"\n";
|
||||||
|
|
||||||
int c;
|
int c;
|
||||||
int uid = 0, gid = 0;
|
int uid = -1, gid = -1;
|
||||||
int readiness = -1;
|
int readiness = -1;
|
||||||
const char *socket_path = getenv("SEATD_SOCK");
|
const char *socket_path = getenv("SEATD_SOCK");
|
||||||
while ((c = getopt(argc, argv, "vhn:s:g:u:")) != -1) {
|
while ((c = getopt(argc, argv, "vhn:s:g:u:")) != -1) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue