diff options
| author | Mattias Andrée <maandree@operamail.com> | 2014-10-29 19:06:17 +0100 |
|---|---|---|
| committer | Mattias Andrée <maandree@operamail.com> | 2014-10-29 19:06:17 +0100 |
| commit | 489de1005c94bda6ea2d3f8d0b8535be191cf16e (patch) | |
| tree | 5a59f8a8662716f9f1034873b0cc0696170c5768 /src/log-login-utmp.c | |
| parent | add log-login-utmp (diff) | |
| download | cerberus-logging-489de1005c94bda6ea2d3f8d0b8535be191cf16e.tar.gz cerberus-logging-489de1005c94bda6ea2d3f8d0b8535be191cf16e.tar.bz2 cerberus-logging-489de1005c94bda6ea2d3f8d0b8535be191cf16e.tar.xz | |
more code reuse
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/log-login-utmp.c')
| -rw-r--r-- | src/log-login-utmp.c | 41 |
1 files changed, 8 insertions, 33 deletions
diff --git a/src/log-login-utmp.c b/src/log-login-utmp.c index c696243..081c63e 100644 --- a/src/log-login-utmp.c +++ b/src/log-login-utmp.c @@ -17,46 +17,21 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "common.h" - #include <utmp.h> - -#define X(A) static const char* A = NULL; - LIST_ARGUMENTS -#undef X - - -static int log_action(void); - - -int main(int argc, char** argv) -{ - int i; - - for (i = 1; i < argc; i++) - { -#define X(A) if (strstr(argv[i], "--" #A "=")) A = strchr(argv[i], '=') + 1; - LIST_ARGUMENTS -#undef X - } - - if (!streq(action, "login")) return 0; - if (NULL == username) return 1; - if (NULL == ttyname) return 1; - if (NULL == pid) return 1; - - return -log_action(); -} - - -static int log_action(void) +int do_log(void) { struct utmp ut; struct utmp *entry; - pid_t pid_ = (pid_t)atoll(pid); - const char* ttyno = first_digit(ttyname); + pid_t pid_; + const char* ttyno; + if (!streq(action, "login")) + return 0; + + pid_ = (pid_t)atoll(pid); + ttyno = first_digit(ttyname); memset(&ut, 0, sizeof(struct utmp)); utmpname(_PATH_UTMP); |
