diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2019-01-06 18:11:02 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2019-01-06 18:11:02 +0000 |
commit | 48c4cf945317e6fd397a8ec4a918461fad96265f (patch) | |
tree | 2ffd82bdc529749fab9f9c054eec108c882d050d /src | |
parent | 62ca2e2698fbd0cc94b40bdc8d355a3a5d1ea239 (diff) | |
download | utmps-48c4cf945317e6fd397a8ec4a918461fad96265f.tar.gz utmps-48c4cf945317e6fd397a8ec4a918461fad96265f.tar.xz utmps-48c4cf945317e6fd397a8ec4a918461fad96265f.zip |
version: 0.0.2.0 v0.0.2.0
utmps-wtmpd bugfix utmps-utmpd allows utmp group to write to utmp file
Diffstat (limited to 'src')
-rw-r--r-- | src/utmps/utmps-utmpd.c | 14 | ||||
-rw-r--r-- | src/utmps/utmps-wtmpd.c | 2 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/utmps/utmps-utmpd.c b/src/utmps/utmps-utmpd.c index cde2ea0..06f3e9e 100644 --- a/src/utmps/utmps-utmpd.c +++ b/src/utmps/utmps-utmpd.c @@ -140,12 +140,16 @@ static void do_getline (void) flush1() ; } -static void do_putline (uid_t uid) +static void do_putline (uid_t uid, gid_t gid) { struct utmpx u ; char buf[sizeof(struct utmpx)] ; get0(buf, sizeof(struct utmpx)) ; - if (uid) { answer(EPERM) ; return ; } + if (uid && gid != getegid()) + { + answer(EPERM) ; + return ; + } utmps_utmpx_unpack(buf, &u) ; maybe_open() ; for (;;) @@ -186,11 +190,15 @@ static void do_rewind (void) int main (void) { uid_t uid ; + gid_t gid ; char const *x ; PROG = "utmps-utmpd" ; x = ucspi_get("REMOTEEUID") ; if (!x) strerr_diefu1x(100, "get $IPCREMOTEEUID from environment") ; if (!uid0_scan(x, &uid)) strerr_dieinvalid(100, "IPCREMOTEEUID") ; + x = ucspi_get("REMOTEEGID") ; + if (!x) strerr_diefu1x(100, "get $IPCREMOTEEGID from environment") ; + if (!gid0_scan(x, &gid)) strerr_dieinvalid(100, "IPCREMOTEEGID") ; if (ndelay_on(0) < 0) strerr_diefu1sys(111, "set stdin non-blocking") ; tain_now_g() ; @@ -205,7 +213,7 @@ int main (void) case 'e' : do_getent() ; break ; case 'i' : do_getid() ; break ; case 'l' : do_getline() ; break ; - case 'E' : do_putline(uid) ; break ; + case 'E' : do_putline(uid, gid) ; break ; case 'r' : do_rewind() ; break ; default : errno = EPROTO ; diff --git a/src/utmps/utmps-wtmpd.c b/src/utmps/utmps-wtmpd.c index c38168a..7aff741 100644 --- a/src/utmps/utmps-wtmpd.c +++ b/src/utmps/utmps-wtmpd.c @@ -89,7 +89,7 @@ int main (void) answer(errno) ; strerr_diefu1sys(111, "lseek on wtmp") ; } - w = allwrite(fd, buf + 1, sizeof(struct utmpx)) ; + w = allwrite(fd, buf, sizeof(struct utmpx)) ; if (w < sizeof(struct utmpx)) { int e = errno ; |