Re: [PATCH 6/7] Add an autologin feature

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, May 09, 2011 at 03:52:39PM +0200, Werner Fink wrote:
> Add an autologin feature to agetty, that is that a user can be
> automatically logged in.  For this the options of for the
> login program has to used.  Make it possible to pass-through
> options to the login program which requires a security check.

 Applied, thanks.

> +	strncpy(logcmd, options.login, NAME_MAX);
> +	strncat(logcmd, " ", NAME_MAX - strlen(logcmd));
> +	strncat(logcmd, options.logopt, NAME_MAX - strlen(logcmd));

 I have added a new function append().

> +		{  "login-options",  required_argument,  0,  'o'  },
> +		{  "loginopts",	     required_argument,  0,  'o'  },  /* compat option */
> +		{  "logopts",	     required_argument,  0,  'o'  },  /* compat option */

 Frankly, the aliases suck ;-) I have removed all aliases and renamed
 the options to "--login-<foo>" format.

> +		{  "loginpause",     no_argument,        0,  'p'  },

 e.g.  --login-pause

> +#ifdef KDGKBLED
> +	if (op->autolog == (char*)0 && (op->flags & F_VCONSOLE)) {
> +		int kb = 0, nl = 0;
> +		struct stat st;
> +		if (stat("/var/run/numlock-on", &st) == 0)
> +			nl = 1;
> +		if (ioctl(STDIN_FILENO, KDGKBLED, &kb) == 0) {
> +			const char *hint = _("Hint: ");
> +			char warn[256];
> +			off_t space = sizeof(warn) - 1, off = 0;
> +
> +			if (nl && (kb & 0x02) == 0) {
> +				const char *msg = _("Num Lock off");
> +				const size_t len = strlen(msg);
> +				strncpy(&warn[0], msg, space);
> +				space -= len;
> +				off += len;
> +			} else if (nl == 0 && (kb & 2) && (kb & 0x20) == 0) {
> +				const char *msg = _("Num Lock on");
> +				const size_t len = strlen(msg);
> +				strncpy(&warn[0], msg, space);
> +				space -= len;
> +				off += len;
> +			}
> +			if ((kb & 0x04) && (kb & 0x40) == 0) {
> +				const char *msg = _("Caps Lock on");
> +				const size_t len = strlen(msg);
> +				if (off) {
> +					strncpy(&warn[off], ", ", space);
> +					space -= 2;
> +					off += 2;
> +				}
> +				strncpy(&warn[off], msg, space);
> +				space -= len;
> +				off += len;
> +			}
> +			if ((kb & 0x01) && (kb & 0x10) == 0) {
> +				const char *msg = _("Scroll Lock on");
> +				const size_t len = strlen(msg);
> +				if (off) {
> +					strncpy(&warn[off], ", ", space);
> +					space -= 2;
> +					off += 2;
> +				}
> +				strncpy(&warn[off], msg, space);
> +				space -= len;
> +				off += len;
> +			}
> +			if (off)
> +				printf ("%s%s\n\n", hint, warn);
> +		}

 also modified to use append()

    Karel

-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux