Accepting request 502835 from home:mimi_vx:branches:X11:windowmanagers

- drop i3lock-2.5-use-unix2_chkpwd.diff
- use default pam config

OBS-URL: https://build.opensuse.org/request/show/502835
OBS-URL: https://build.opensuse.org/package/show/X11:windowmanagers/i3lock?expand=0&rev=19
This commit is contained in:
Ondřej Súkup 2017-06-11 07:11:58 +00:00 committed by Git OBS Bridge
parent 1a8be36349
commit 6c9f31aaf0
3 changed files with 6 additions and 189 deletions

View File

@ -1,179 +0,0 @@
Author: Stefan Seyfried <seife+obs@b1-systems.com>
Date: Sat Feb 15 14:20:27 2014 +0100
add the option to use unix2_chkpwd instead of needing setgid shadow
Index: i3lock-2.9/Makefile
===================================================================
--- i3lock-2.9.orig/Makefile
+++ i3lock-2.9/Makefile
@@ -21,9 +21,13 @@ LIBS += -lev
LIBS += -lm
# OpenBSD lacks PAM, use bsd_auth(3) instead.
+ifeq ($(USE_UNIX2_CHKPWD),)
++CFLAGS += -DUSE_UNIX2_CHKPWD=1
+else
ifneq ($(UNAME),OpenBSD)
LIBS += -lpam
endif
+endif
FILES:=$(wildcard *.c)
FILES:=$(FILES:.c=.o)
Index: i3lock-2.9/i3lock.c
===================================================================
--- i3lock-2.9.orig/i3lock.c
+++ i3lock-2.9/i3lock.c
@@ -21,8 +21,10 @@
#ifdef __OpenBSD__
#include <bsd_auth.h>
#else
+#ifndef USE_UNIX2_CHKPWD
#include <security/pam_appl.h>
#endif
+#endif
#include <getopt.h>
#include <string.h>
#include <ev.h>
@@ -36,6 +38,13 @@
#include <strings.h> /* explicit_bzero(3) */
#endif
+#ifdef USE_UNIX2_CHKPWD
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <pwd.h>
+#include <errno.h>
+#endif
+
#include "i3lock.h"
#include "xcb.h"
#include "cursors.h"
@@ -57,8 +66,10 @@ uint32_t last_resolution[2];
xcb_window_t win;
static xcb_cursor_t cursor;
#ifndef __OpenBSD__
+#ifndef USE_UNIX2_CHKPWD
static pam_handle_t *pam_handle;
#endif
+#endif
int input_position = 0;
/* Holds the password you enter (in UTF-8). */
static char password[512];
@@ -243,6 +254,62 @@ static void clear_auth_wrong(EV_P_ ev_ti
if (retry_verification) {
retry_verification = false;
finish_input();
+#ifdef USE_UNIX2_CHKPWD
+ struct passwd *pw;
+
+ pw = getpwuid(getuid());
+ if (! pw)
+ perror("i3lock: getpwuid() failed");
+ else {
+ int pfd[2], status;
+ pid_t pid;
+
+ if (pipe(pfd) < 0) {
+ perror("i3lock: pipe() failed");
+ goto auth_failed;
+ }
+
+ if ((pid = fork()) < 0) {
+ perror("i3lock: fork() failed");
+ close(pfd[0]);
+ close(pfd[1]);
+ goto auth_failed;
+ }
+
+ if (pid == 0) {
+ close(pfd[1]);
+ if (pfd[0] != 0)
+ dup2(pfd[0], 0);
+
+ /* Helper is invoked as helper service-name [user] */
+ printf("calling '/sbin/unix2_chkpwd i3lock %s'\n", pw->pw_name);
+ execlp("/sbin/unix2_chkpwd", "/sbin/unix2_chkpwd", "i3lock", pw->pw_name, NULL);
+ perror("i3lock: execlp(/sbin/unix2_chkpwd)");
+ exit(1);
+ }
+
+ close(pfd[0]);
+ /* Write out password to helper process */
+ write(pfd[1], password, strlen(password));
+ close(pfd[1]);
+
+ while (waitpid(pid, &status, 0) < 0) {
+ if (errno == EINTR)
+ continue;
+ perror("i3lock: waitpid() failed");
+ goto auth_failed;
+ }
+
+ if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
+ goto auth_failed;
+ endpwent();
+ DEBUG("successfully authenticated\n");
+ clear_password_memory();
+ exit(0);
+ }
+ auth_failed:
+ endpwent();
+#else
}
}
@@ -256,7 +323,7 @@ static void clear_input(void) {
clear_password_memory();
password[input_position] = '\0';
}
-
+#endif
static void discard_passwd_cb(EV_P_ ev_timer *w, int revents) {
clear_input();
STOP_TIMER(discard_passwd_timeout);
@@ -592,6 +659,7 @@ static void process_xkb_event(xcb_generi
}
}
+#ifndef USE_UNIX2_CHKPWD
/*
* Called when the properties on the root window change, e.g. when the screen
* resolution changes. If so we update the window to cover the whole screen
@@ -625,6 +693,7 @@ void handle_screen_resize(void) {
xinerama_query_screens();
redraw_screen();
}
+#endif
#ifndef __OpenBSD__
/*
@@ -814,9 +883,11 @@ int main(int argc, char *argv[]) {
char *username;
char *image_path = NULL;
#ifndef __OpenBSD__
+#ifndef USE_UNIX2_CHKPWD
int ret;
struct pam_conv conv = {conv_callback, NULL};
#endif
+#endif
int curs_choice = CURS_NONE;
int o;
int optind = 0;
@@ -911,6 +982,7 @@ int main(int argc, char *argv[]) {
srand(time(NULL));
#ifndef __OpenBSD__
+#ifndef USE_UNIX2_CHKPWD
/* Initialize PAM */
if ((ret = pam_start("i3lock", username, &conv, &pam_handle)) != PAM_SUCCESS)
errx(EXIT_FAILURE, "PAM: %s", pam_strerror(pam_handle, ret));
@@ -918,6 +990,7 @@ int main(int argc, char *argv[]) {
if ((ret = pam_set_item(pam_handle, PAM_TTY, getenv("DISPLAY"))) != PAM_SUCCESS)
errx(EXIT_FAILURE, "PAM: %s", pam_strerror(pam_handle, ret));
#endif
+#endif
/* Using mlock() as non-super-user seems only possible in Linux.
* Users of other operating systems should use encrypted swap/no swap

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Sun Jun 11 07:09:22 UTC 2017 - mimi.vx@gmail.com
- drop i3lock-2.5-use-unix2_chkpwd.diff
- use default pam config
-------------------------------------------------------------------
Sat Jun 10 13:34:49 UTC 2017 - mimi.vx@gmail.com

View File

@ -27,12 +27,9 @@ License: BSD-3-Clause
Group: System/GUI/Other
Url: http://i3wm.org/i3lock/
Source: http://i3wm.org/i3lock/i3lock-%{version}.tar.bz2
Source1: i3lock.pam
# borrowed from gnome-icon-theme
Source2: i3lock-icon.png
Source3: xlock.sh
# PATCH-FEATURE-OPENSUSE i3lock-2.5-use-unix2_chkpwd.diff -- seife+obs@b1-systems.com
Patch1: i3lock-2.5-use-unix2_chkpwd.diff
BuildRequires: gcc
BuildRequires: glibc-devel
BuildRequires: libudev1
@ -68,29 +65,22 @@ i3lock instead of xlock with them.
%prep
%setup -q
%patch1 -p1
%build
export CFLAGS="%{optflags}"
make %{?_smp_mflags} \
USE_UNIX2_CHKPWD=1 \
PREFIX="%{_prefix}" \
SYSCONFDIR="%{_sysconfdir}"
%install
export CFLAGS="%{optflags}"
make \
USE_UNIX2_CHKPWD=1 \
PREFIX="%{_prefix}" \
SYSCONFDIR="%{_sysconfdir}" \
DESTDIR=%{buildroot} \
install
rm "%{buildroot}%{_sysconfdir}/pam.d/i3lock"
install -m0644 "%{SOURCE1}" "%{buildroot}%{_sysconfdir}/pam.d/%{name}"
install -D -m0644 i3lock.1 "%{buildroot}%{_mandir}/man1/i3lock.1"
install -D -m0644 %{SOURCE2} %{buildroot}%{_datadir}/i3lock-xlock-compat/i3lock-icon.png
install -m0755 %{SOURCE3} %{buildroot}/%{_bindir}/xlock