X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Futmp.c;h=3852cae9b79c0bf78a5d100fc82f9172a68bec88;hb=e8db7f6eea9b35527ddd4532affabd18a30549b5;hp=427cdc50f04550b72fd7b5222c789ce178a27f9b;hpb=2e444a5714593fb7659157cee2e7037577c0bdcd;p=debian%2Fsudo diff --git a/src/utmp.c b/src/utmp.c index 427cdc5..3852cae 100644 --- a/src/utmp.c +++ b/src/utmp.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 Todd C. Miller + * Copyright (c) 2011-2013 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -17,7 +17,6 @@ #include #include -#include #include #include #include @@ -53,6 +52,7 @@ # include #endif #include +#include #include "sudo.h" #include "sudo_exec.h" @@ -275,12 +275,12 @@ utmp_slot(const char *line, int ttyfd) * doesn't take an argument. */ if ((sfd = dup(STDIN_FILENO)) == -1) - error(1, _("unable to save stdin")); + fatal(_("unable to save stdin")); if (dup2(ttyfd, STDIN_FILENO) == -1) - error(1, _("unable to dup2 stdin")); + fatal(_("unable to dup2 stdin")); slot = ttyslot(); if (dup2(sfd, STDIN_FILENO) == -1) - error(1, _("unable to restore stdin")); + fatal(_("unable to restore stdin")); close(sfd); debug_return_int(slot); @@ -327,7 +327,11 @@ utmp_login(const char *from_line, const char *to_line, int ttyfd, } } utmp_fill(to_line, user, ut_old, &utbuf); +#ifdef HAVE_FSEEKO + if (fseeko(fp, slot * (off_t)sizeof(utbuf), SEEK_SET) == 0) { +#else if (fseek(fp, slot * (long)sizeof(utbuf), SEEK_SET) == 0) { +#endif if (fwrite(&utbuf, sizeof(utbuf), 1, fp) == 1) rval = true; } @@ -360,7 +364,11 @@ utmp_logout(const char *line, int status) # endif utmp_settime(&utbuf); /* Back up and overwrite record. */ +#ifdef HAVE_FSEEKO + if (fseeko(fp, (off_t)0 - (off_t)sizeof(utbuf), SEEK_CUR) == 0) { +#else if (fseek(fp, 0L - (long)sizeof(utbuf), SEEK_CUR) == 0) { +#endif if (fwrite(&utbuf, sizeof(utbuf), 1, fp) == 1) rval = true; }