[hackers] [ubase] Add initial implementation of login(1) || sin

From: <git_AT_suckless.org>
Date: Mon, 02 Jun 2014 17:17:37 +0200

commit 0a3ed68d2500c2989545b3bf0af5ebc0b50bec7a
Author: sin <sin_AT_2f30.org>
Date: Mon Jun 2 14:00:55 2014 +0100

    Add initial implementation of login(1)
    
    No shadow support atm.

diff --git a/Makefile b/Makefile
index ac61c7d..fe87548 100644
--- a/Makefile
+++ b/Makefile
_AT_@ -32,6 +32,7 @@ SRC = \
         id.c \
         insmod.c \
         killall5.c \
+ login.c \
         lsmod.c \
         lsusb.c \
         mknod.c \
diff --git a/login.c b/login.c
new file mode 100644
index 0000000..3adf188
--- /dev/null
+++ b/login.c
_AT_@ -0,0 +1,109 @@
+/* See LICENSE file for copyright and license details. */
+#define _XOPEN_SOURCE
+#include <errno.h>
+#include <grp.h>
+#include <pwd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include "config.h"
+#include "util.h"
+
+static int dologin(struct passwd *, int);
+
+static void
+usage(void)
+{
+ eprintf("usage: %s [-p] username
", argv0);
+}
+
+int
+main(int argc, char *argv[])
+{
+ struct passwd *pw;
+ uid_t uid;
+ gid_t gid;
+ char *pass, *cryptpass;
+ int pflag = 0;
+
+ ARGBEGIN {
+ case 'p':
+ pflag = 1;
+ break;
+ default:
+ usage();
+ } ARGEND;
+
+ if (argc < 1)
+ usage();
+
+ errno = 0;
+ pw = getpwnam(argv[0]);
+ if (errno)
+ eprintf("getpwnam: %s:", argv[0]);
+ else if (!pw)
+ eprintf("who are you?
");
+
+ switch (pw->pw_passwd[0]) {
+ case '!':
+ case '*':
+ eprintf("Denied
");
+ }
+
+ if (pw->pw_passwd[0] == 'x' && pw->pw_passwd[1] == '
Received on Mon Jun 02 2014 - 17:17:37 CEST

This archive was generated by hypermail 2.3.0 : Mon Jun 02 2014 - 17:24:09 CEST