compiles on openbsd

master
Alessandro Mauri 3 years ago
parent fb6c872dc7
commit 9494b18325
  1. 1
      .gitignore
  2. 4
      makefile
  3. 7
      us.c

1
.gitignore vendored

@ -0,0 +1 @@
us

@ -1,7 +1,7 @@
CC ?= gcc
CFLAGS = -Wall -pedantic --std=c99 -O2
DBG_CFLAGS = -Wall -Werror -pedantic --std=c99 -O0 -g
LDFLAGS = -lcrypt
LDFLAGS != if [ "$(uname)" = 'Linux' ]; then printf '-lcrypt'; fi
PREFIX = /usr/local
MANPREFIX = ${PREFIX}/share/man
@ -13,7 +13,7 @@ dbg:
install: us
mkdir -p ${DESTDIR}${PREFIX}/bin
cp -f us ${DESTDIR}${PREFIX}/bin/us
chown root:root ${DESTDIR}${PREFIX}/bin/us
chown 0:0 ${DESTDIR}${PREFIX}/bin/us
chmod 4755 ${DESTDIR}${PREFIX}/bin/us
# mkdir -p ${DESTDIR}${MANPREFIX}/man1
# cp -f us.1 ${DESTDIR}${MANPREFIX}/man1/us.1

@ -17,7 +17,11 @@
*/
#define _POSIX_C_SOURCE 200809L
#ifdef __linux__
#define _DEFAULT_SOURCE
#else
#define _BSD_SOURCE
#endif
#include <sys/types.h>
#include <sys/wait.h>
@ -298,7 +302,6 @@ static int authenticate(uid_t uid, char ask)
if (!op)
die("getpwuid_shadow:");
hash_p = op->pw_passwd;
exit(EXIT_FAILURE);
#endif
} else {
hash_p = pw->pw_passwd;
@ -374,7 +377,7 @@ static int authenticate(uid_t uid, char ask)
char *enc = crypt(pass, hash);
memset(pass, 0, 1024);
if (strcmp(enc, hash)) {
if (strncmp(hash, enc, 1024)) {
printf("Authentication failure\n");
setuid(uid);
return -1;

Loading…
Cancel
Save