From owner-svn-ports-all@FreeBSD.ORG Thu Oct 10 08:18:55 2013 Return-Path: Delivered-To: svn-ports-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 79C04249; Thu, 10 Oct 2013 08:18:55 +0000 (UTC) (envelope-from gahr@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 677D428CB; Thu, 10 Oct 2013 08:18:55 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r9A8ItUS074490; Thu, 10 Oct 2013 08:18:55 GMT (envelope-from gahr@svn.freebsd.org) Received: (from gahr@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r9A8It5q074488; Thu, 10 Oct 2013 08:18:55 GMT (envelope-from gahr@svn.freebsd.org) Message-Id: <201310100818.r9A8It5q074488@svn.freebsd.org> From: Pietro Cerutti Date: Thu, 10 Oct 2013 08:18:55 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r329974 - in head/x11/slock: . files X-SVN-Group: ports-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Oct 2013 08:18:55 -0000 Author: gahr Date: Thu Oct 10 08:18:54 2013 New Revision: 329974 URL: http://svnweb.freebsd.org/changeset/ports/329974 Log: - Take maintainership [1] - Add PAM support ("slock" service) Approved by: bapt (former maintainer) [1] Added: head/x11/slock/files/ head/x11/slock/files/patch-pam (contents, props changed) Modified: head/x11/slock/Makefile Modified: head/x11/slock/Makefile ============================================================================== --- head/x11/slock/Makefile Thu Oct 10 08:13:00 2013 (r329973) +++ head/x11/slock/Makefile Thu Oct 10 08:18:54 2013 (r329974) @@ -6,7 +6,7 @@ PORTVERSION= 1.1 CATEGORIES= x11 MASTER_SITES= http://dl.suckless.org/tools/ -MAINTAINER= bapt@FreeBSD.org +MAINTAINER= gahr@FreeBSD.org COMMENT= Simple X screen locker MAKE_ARGS= PREFIX="${PREFIX}" X11LIB="${LOCALBASE}/lib" \ @@ -21,6 +21,7 @@ USE_XORG= x11 xt xproto xext post-patch: @${REINPLACE_CMD} -e 's|-I/usr/include||;s|-L/usr/lib||;s|= -Os|+=|'\ - -e 's|-DHAVE_SHADOW_H||' ${WRKSRC}/config.mk + -e 's|-DHAVE_SHADOW_H|-DHAVE_PAM|' -e '/^LDFLAGS/s|$$| -lpam|' \ + ${WRKSRC}/config.mk .include Added: head/x11/slock/files/patch-pam ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/x11/slock/files/patch-pam Thu Oct 10 08:18:54 2013 (r329974) @@ -0,0 +1,116 @@ +--- config.mk.orig 2013-10-09 16:23:24.000000000 +0200 ++++ config.mk 2013-10-09 16:25:18.000000000 +0200 +@@ -18,6 +18,9 @@ + CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS} + LDFLAGS = -s ${LIBS} + ++# To enable PAM-based authentication, remove -DHAVE_SHADOW_H from CPPFLAGS ++# and add -DHAVE_PAM instead. Also, add -lpam to LDFLAGS. ++# + # On *BSD remove -DHAVE_SHADOW_H from CPPFLAGS and add -DHAVE_BSD_AUTH + # On OpenBSD and Darwin remove -lcrypt from LIBS + +--- slock.c.orig 2013-10-09 16:23:14.000000000 +0200 ++++ slock.c 2013-10-09 16:23:18.000000000 +0200 +@@ -23,6 +23,10 @@ + #include + #endif + ++#if HAVE_PAM ++#include ++#endif ++ + typedef struct { + int screen; + Window root, win; +@@ -44,7 +48,7 @@ + exit(EXIT_FAILURE); + } + +-#ifndef HAVE_BSD_AUTH ++#if !defined(HAVE_BSD_AUTH) && !defined(HAVE_PAM) + static const char * + getpw(void) { /* only run as root */ + const char *rval; +@@ -74,8 +78,41 @@ + } + #endif + ++#ifdef HAVE_PAM ++static int ++slock_conv (int nof_msg, const struct pam_message **msg, struct pam_response **resp, void *data) { ++ struct pam_response *r = calloc (nof_msg, sizeof **resp); ++ if (r == NULL) { ++ die("slock: malloc: %s", strerror(errno)); ++ } ++ ++ while (nof_msg--) { ++ r[nof_msg].resp_retcode = 0; ++ r[nof_msg].resp = strdup (data); ++ } ++ ++ *resp = r; ++ ++ return PAM_SUCCESS; ++} ++ ++static int ++auth_pam (const char *user, char *pass) { ++ static struct pam_conv conv = {slock_conv, NULL}; ++ pam_handle_t *ph; ++ ++ conv.appdata_ptr = pass; ++ ++ if (pam_start("slock", user, &conv, &ph) != PAM_SUCCESS) { ++ die("slock: pam_start"); ++ } ++ ++ return (pam_authenticate(ph, 0) == PAM_SUCCESS); ++} ++#endif ++ + static void +-#ifdef HAVE_BSD_AUTH ++#if defined(HAVE_BSD_AUTH) || defined(HAVE_PAM) + readpw(Display *dpy) + #else + readpw(Display *dpy, const char *pws) +@@ -111,8 +148,10 @@ + switch(ksym) { + case XK_Return: + passwd[len] = 0; +-#ifdef HAVE_BSD_AUTH ++#if defined (HAVE_BSD_AUTH) + running = !auth_userokay(getlogin(), NULL, "auth-xlock", passwd); ++#elif defined (HAVE_PAM) ++ running = !auth_pam(getlogin(), passwd); + #else + running = strcmp(crypt(passwd, pws), pws); + #endif +@@ -233,7 +272,7 @@ + + int + main(int argc, char **argv) { +-#ifndef HAVE_BSD_AUTH ++#if !defined(HAVE_BSD_AUTH) && !defined(HAVE_PAM) + const char *pws; + #endif + Display *dpy; +@@ -247,7 +286,7 @@ + if(!getpwuid(getuid())) + die("slock: no passwd entry for you"); + +-#ifndef HAVE_BSD_AUTH ++#if !defined(HAVE_BSD_AUTH) && !defined(HAVE_PAM) + pws = getpw(); + #endif + +@@ -273,7 +312,7 @@ + } + + /* Everything is now blank. Now wait for the correct password. */ +-#ifdef HAVE_BSD_AUTH ++#if defined(HAVE_BSD_AUTH) || defined(HAVE_PAM) + readpw(dpy); + #else + readpw(dpy, pws);