From 0fc7654a83fe5b7d43bf9c71c13e6d48327630c2 Mon Sep 17 00:00:00 2001 From: Claudio Matsuoka Date: Mon, 2 Jun 2008 17:22:35 -0300 Subject: [PATCH] Set owner of /var/run/utmp to root:utmp Signed-off-by: Claudio Matsuoka --- Changelog | 1 + finit-alt.c | 2 ++ helpers.c | 12 ++++++++++++ helpers.h | 1 + 4 files changed, 16 insertions(+) diff --git a/Changelog b/Changelog index 6fa98a08..d3d64cf2 100644 --- a/Changelog +++ b/Changelog @@ -1,6 +1,7 @@ 0.5 () - finit-alt listens to /dev/initctl to work with reboot(8) - write runlevel to utmp, needed by Printerdrake (by Pascal Terjan) + - fix ownership of /var/run/utmp (reported by Pascal Terjan) O.4 (20080516) - default username for finit-alt configurable in Makefile diff --git a/finit-alt.c b/finit-alt.c index cf057add..9143d58d 100644 --- a/finit-alt.c +++ b/finit-alt.c @@ -325,6 +325,8 @@ int main() } touch("/var/run/utmp"); + chown("/var/run/utmp", 0, getgroup("utmp")); + #ifdef RUNLEVEL memset(&entry, 0, sizeof(struct utmp)); entry.ut_type = RUN_LVL; diff --git a/helpers.c b/helpers.c index ddb6f0f7..03ecd687 100644 --- a/helpers.c +++ b/helpers.c @@ -17,6 +17,8 @@ #include #endif +#include + #include "helpers.h" /* @@ -157,6 +159,16 @@ int run_parts(char *dir, ...) return 0; } +int getgroup(char *s) +{ + struct group *grp; + + if ((grp = getgrnam(s)) == NULL) + return -1; + + return grp->gr_gid; +} + /* * Other convenience functions */ diff --git a/helpers.h b/helpers.h index 8f989a15..945aa528 100644 --- a/helpers.h +++ b/helpers.h @@ -5,6 +5,7 @@ int makepath (char *); void ifconfig (char *, char *, char *, int); void copyfile (char *, char *, int); void chomp (char *); +int getgroup (char *); #ifdef BUILTIN_RUNPARTS int run_parts (char *, ...);