[Pkg-shadow-commits] r2426 - in upstream/trunk: . src
nekral-guest at alioth.debian.org
nekral-guest at alioth.debian.org
Sat Sep 20 16:21:47 UTC 2008
Author: nekral-guest
Date: 2008-09-20 16:21:46 +0000 (Sat, 20 Sep 2008)
New Revision: 2426
Modified:
upstream/trunk/ChangeLog
upstream/trunk/src/login.c
Log:
* src/login.c: check_flags() renamed process_flags(). All flag
processing blocs moved to process_flags().
Modified: upstream/trunk/ChangeLog
===================================================================
--- upstream/trunk/ChangeLog 2008-09-20 14:56:10 UTC (rev 2425)
+++ upstream/trunk/ChangeLog 2008-09-20 16:21:46 UTC (rev 2426)
@@ -1,5 +1,10 @@
2008-09-20 Nicolas François <nicolas.francois at centraliens.net>
+ * src/login.c: check_flags() renamed process_flags(). All flag
+ processing blocs moved to process_flags().
+
+2008-09-20 Nicolas François <nicolas.francois at centraliens.net>
+
* src/logoutd.c, src/userdel.c: Re-indent. This helps pmccabe.
2008-09-20 Nicolas François <nicolas.francois at centraliens.net>
Modified: upstream/trunk/src/login.c
===================================================================
--- upstream/trunk/src/login.c 2008-09-20 14:56:10 UTC (rev 2425)
+++ upstream/trunk/src/login.c 2008-09-20 16:21:46 UTC (rev 2426)
@@ -78,8 +78,12 @@
/*
* Global variables
*/
-const char *hostname = "";
+char *Prog;
+static const char *hostname = "";
+static char username[32];
+static int reason = PW_LOGIN;
+
static struct passwd pwent;
#if HAVE_UTMPX_H
@@ -102,11 +106,6 @@
static bool hflg = false;
static bool preauth_flag = false;
-/*
- * Global variables.
- */
-char *Prog;
-
static bool amroot;
static int timeout;
@@ -129,7 +128,7 @@
/* local function prototypes */
static void usage (void);
static void setup_tty (void);
-static void check_flags (int, char *const *);
+static void process_flags (int, char *const *);
#ifndef USE_PAM
static struct faillog faillog;
@@ -244,10 +243,13 @@
}
#endif /* !USE_PAM */
-static void check_flags (int argc, char *const *argv)
+static void process_flags (int argc, char *const *argv)
{
int arg;
+ int flag;
+ username[0] = '\0';
+
/*
* Check the flags for proper form. Every argument starting with
* "-" must be exactly two characters long. This closes all the
@@ -261,6 +263,84 @@
break; /* stop checking on a "--" */
}
}
+
+ /*
+ * Process options.
+ */
+ while ((flag = getopt (argc, argv, "d:f::h:pr:")) != EOF) {
+ switch (flag) {
+ case 'd':
+ /* "-d device" ignored for compatibility */
+ break;
+ case 'f':
+ /*
+ * username must be a separate token
+ * (-f root, *not* -froot). --marekm
+ *
+ * if -f has an arg, use that, else use the
+ * normal user name passed after all options
+ * --benc
+ */
+ if (optarg != NULL && optarg != argv[optind - 1]) {
+ usage ();
+ }
+ fflg = true;
+ if (optarg) {
+ STRFCPY (username, optarg);
+ }
+ break;
+ case 'h':
+ hflg = true;
+ hostname = optarg;
+ reason = PW_TELNET;
+ break;
+#ifdef RLOGIN
+ case 'r':
+ rflg = true;
+ hostname = optarg;
+ reason = PW_RLOGIN;
+ break;
+#endif
+ case 'p':
+ pflg = true;
+ break;
+ default:
+ usage ();
+ }
+ }
+
+#ifdef RLOGIN
+ /*
+ * Neither -h nor -f should be combined with -r.
+ */
+
+ if (rflg && (hflg || fflg)) {
+ usage ();
+ }
+#endif
+
+ /*
+ * Allow authentication bypass only if real UID is zero.
+ */
+
+ if ((rflg || fflg || hflg) && !amroot) {
+ fprintf (stderr, _("%s: Permission denied.\n"), Prog);
+ exit (1);
+ }
+
+ /*
+ * Get the user name.
+ */
+ if (optind < argc) {
+ if (rflg || (fflg && ('\0' != username[0]))) {
+ usage ();
+ }
+
+ STRFCPY (username, argv[optind]);
+ strzero (argv[optind]);
+ ++optind;
+ }
+
}
@@ -337,7 +417,6 @@
*/
int main (int argc, char **argv)
{
- char username[32];
char tty[BUFSIZ];
#ifdef RLOGIN
@@ -346,11 +425,9 @@
#if defined(HAVE_STRFTIME) && !defined(USE_PAM)
char ptime[80];
#endif
- int reason = PW_LOGIN;
int delay;
int retries;
bool failed;
- int flag;
bool subroot = false;
#ifndef USE_PAM
bool is_console;
@@ -384,73 +461,11 @@
initenv ();
- username[0] = '\0';
amroot = (getuid () == 0);
Prog = Basename (argv[0]);
- check_flags (argc, argv);
+ process_flags (argc, argv);
- while ((flag = getopt (argc, argv, "d:f::h:pr:")) != EOF) {
- switch (flag) {
- case 'd':
- /* "-d device" ignored for compatibility */
- break;
- case 'f':
- /*
- * username must be a separate token
- * (-f root, *not* -froot). --marekm
- *
- * if -f has an arg, use that, else use the
- * normal user name passed after all options
- * --benc
- */
- if (optarg != NULL && optarg != argv[optind - 1]) {
- usage ();
- }
- fflg = true;
- if (optarg) {
- STRFCPY (username, optarg);
- }
- break;
- case 'h':
- hflg = true;
- hostname = optarg;
- reason = PW_TELNET;
- break;
-#ifdef RLOGIN
- case 'r':
- rflg = true;
- hostname = optarg;
- reason = PW_RLOGIN;
- break;
-#endif
- case 'p':
- pflg = true;
- break;
- default:
- usage ();
- }
- }
-
-#ifdef RLOGIN
- /*
- * Neither -h nor -f should be combined with -r.
- */
-
- if (rflg && (hflg || fflg)) {
- usage ();
- }
-#endif
-
- /*
- * Allow authentication bypass only if real UID is zero.
- */
-
- if ((rflg || fflg || hflg) && !amroot) {
- fprintf (stderr, _("%s: Permission denied.\n"), Prog);
- exit (1);
- }
-
if ((isatty (0) == 0) || (isatty (1) == 0) || (isatty (2) == 0)) {
exit (1); /* must be a terminal */
}
@@ -571,15 +586,6 @@
init_env ();
- if (optind < argc) { /* get the user name */
- if (rflg || (fflg && ('\0' != username[0]))) {
- usage ();
- }
-
- STRFCPY (username, argv[optind]);
- strzero (argv[optind]);
- ++optind;
- }
if (optind < argc) { /* now set command line variables */
set_env (argc - optind, &argv[optind]);
}
More information about the Pkg-shadow-commits
mailing list