Ignore:
Timestamp:
Nov 4, 2007, 3:16:40 AM (16 years ago)
Author:
Bruno Cornec
Message:

Update to busybox 1.7.2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.5/mindi-busybox/loginutils/vlock.c

    r821 r1765  
    11/* vi: set sw=4 ts=4: */
     2
    23/*
    34 * vlock implementation for busybox
     
    1617 * It now works with md5, sha1, etc passwords. */
    1718
    18 #include <stdio.h>
    19 #include <stdlib.h>
     19#include "libbb.h"
    2020#include <sys/vt.h>
    21 #include <signal.h>
    22 #include <string.h>
    23 #include <unistd.h>
    24 #include <fcntl.h>
    25 #include <errno.h>
    26 #include <sys/ioctl.h>
    27 #include <termios.h>
    28 
    29 #include "busybox.h"
    3021
    3122static struct passwd *pw;
     
    3728static void release_vt(int signo)
    3829{
    39     if (!o_lock_all)
    40         ioctl(vfd, VT_RELDISP, 1);
    41     else
    42         ioctl(vfd, VT_RELDISP, 0);
     30    ioctl(vfd, VT_RELDISP, !o_lock_all);
    4331}
    4432
     
    5442}
    5543
     44int vlock_main(int argc, char **argv);
    5645int vlock_main(int argc, char **argv)
    5746{
     
    6049    struct vt_mode vtm;
    6150    struct termios term;
     51    uid_t uid = getuid();
     52
     53    pw = getpwuid(uid);
     54    if (pw == NULL)
     55        bb_error_msg_and_die("unknown uid %d", uid);
    6256
    6357    if (argc > 2) {
     
    6559    }
    6660
    67     o_lock_all = bb_getopt_ulflags (argc, argv, "a");
     61    o_lock_all = getopt32(argv, "a");
    6862
    69     if((pw = getpwuid(getuid())) == NULL) {
    70         bb_error_msg_and_die("Unknown uid %d", getuid());
    71     }
     63    vfd = xopen(CURRENT_TTY, O_RDWR);
    7264
    73     vfd = bb_xopen(CURRENT_TTY, O_RDWR);
    74 
    75     if (ioctl(vfd, VT_GETMODE, &vtm) < 0) {
    76         bb_perror_msg_and_die("VT_GETMODE");
    77     }
     65    xioctl(vfd, VT_GETMODE, &vtm);
    7866
    7967    /* mask a bunch of signals */
     
    118106
    119107    do {
    120         printf("Virtual Console%s locked.\n%s's ", (o_lock_all) ? "s" : "", pw->pw_name);
    121         fflush(stdout);
    122         if (correct_password (pw)) {
     108        printf("Virtual Console%s locked by %s.\n", (o_lock_all) ? "s" : "", pw->pw_name);
     109        if (correct_password(pw)) {
    123110            break;
    124111        }
    125112        bb_do_delay(FAIL_DELAY);
    126         puts("Password incorrect.");
     113        puts("Password incorrect");
    127114    } while (1);
    128115    restore_terminal();
    129     return 0;
     116    fflush_stdout_and_exit(0);
    130117}
Note: See TracChangeset for help on using the changeset viewer.