summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-01-04 16:30:14 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-01-04 16:30:14 +0100
commitb296e814ae46b695355436adf3750c77aa8d166d (patch)
tree641e701c897223d11cdeee5dc4e24025819a41c9
parent9b2140040471136e99e13806d0d4f88ccd8863fa (diff)
downloadfastd-b296e814ae46b695355436adf3750c77aa8d166d.tar
fastd-b296e814ae46b695355436adf3750c77aa8d166d.zip
Add some debug output to uid/gid switching
-rw-r--r--src/fastd.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/fastd.c b/src/fastd.c
index 3b72922..3e622e2 100644
--- a/src/fastd.c
+++ b/src/fastd.c
@@ -99,9 +99,10 @@ static void init_log(fastd_context_t *ctx) {
gid_t gid = getegid();
if (ctx->conf->user || ctx->conf->group) {
- /* We don't care about errors here */
- setegid(ctx->conf->gid);
- seteuid(ctx->conf->uid);
+ if (setegid(ctx->conf->gid) < 0)
+ pr_debug_errno(ctx, "setegid");
+ if (seteuid(ctx->conf->uid) < 0)
+ pr_debug_errno(ctx, "seteuid");
}
if (ctx->conf->log_syslog_level >= 0)
@@ -118,8 +119,10 @@ static void init_log(fastd_context_t *ctx) {
ctx->log_files = file;
}
- seteuid(uid);
- setegid(gid);
+ if (seteuid(uid) < 0)
+ pr_debug_errno(ctx, "seteuid");
+ if (setegid(gid) < 0)
+ pr_debug_errno(ctx, "setegid");
}
static void close_log(fastd_context_t *ctx) {
@@ -1010,9 +1013,10 @@ static void write_pid(fastd_context_t *ctx, pid_t pid) {
gid_t gid = getegid();
if (ctx->conf->user || ctx->conf->group) {
- /* We don't care about errors here */
- setegid(ctx->conf->gid);
- seteuid(ctx->conf->uid);
+ if (setegid(ctx->conf->gid) < 0)
+ pr_debug_errno(ctx, "setegid");
+ if (seteuid(ctx->conf->uid) < 0)
+ pr_debug_errno(ctx, "seteuid");
}
int fd = open(ctx->conf->pid_file, O_WRONLY|O_CREAT|O_TRUNC, 0666);
@@ -1028,8 +1032,10 @@ static void write_pid(fastd_context_t *ctx, pid_t pid) {
pr_warn_errno(ctx, "close");
end:
- seteuid(uid);
- setegid(gid);
+ if (seteuid(uid) < 0)
+ pr_debug_errno(ctx, "seteuid");
+ if (setegid(gid) < 0)
+ pr_debug_errno(ctx, "setegid");
}
static void set_user(fastd_context_t *ctx) {