accountsservice: minor patch cleanup

Improve library inclusion and explicit linking. Also fix some code
formatting, plus spelling and grammar tweaks. (We still don't
correctly include util.h, because the upstream project uses its
own header file by that name, which is woven all over the place.
That should be fixed later.) Noted while reviewing the NetBSD support
patch set.

The (now rather dated) 0.6.42 release is (co-incidentally?) the last
version before various function signature changes that assume a glibc-
specific structure exists that's passed around. This of course doesn't
work on NetBSD. There's more than one way to fix this: OpenBSD added a
whole bunch more #ifdefs; a more elegant method would be to abstract
these expectations. The upstream project has recently landed a patch
set that sort of does the latter (simply copies the glibc struct if it
isn't found), but that hasn't made it into a release yet.
This commit is contained in:
gutteridge 2023-12-19 00:49:52 +00:00
parent 1e25e6647a
commit 73c6bb6a10
5 changed files with 37 additions and 28 deletions

View File

@ -1,7 +1,7 @@
# $NetBSD: Makefile,v 1.8 2021/12/08 16:02:36 adam Exp $
# $NetBSD: Makefile,v 1.9 2023/12/19 00:49:52 gutteridge Exp $
DISTNAME= accountsservice-0.6.42
PKGREVISION= 3
PKGREVISION= 4
CATEGORIES= sysutils
MASTER_SITES= http://www.freedesktop.org/software/accountsservice/
EXTRACT_SUFX= .tar.xz
@ -24,7 +24,7 @@ CONFIGURE_ARGS+= --disable-systemd \
CONFIGURE_ENV.SunOS+= ac_cv_have_decl_WTMPX_FILENAME=yes
CPPFLAGS.SunOS+= -DWTMPX_FILENAME=WTMPX_FILE
LDFLAGS.NetBSD+= -lutil # pw_getpwconf
LDFLAGS.NetBSD+= -lutil -lcrypt # pw_getpwconf & pw_gensalt
ALL_ENV+= EGDIR=${EGDIR}

View File

@ -1,11 +1,11 @@
$NetBSD: distinfo,v 1.4 2021/10/26 11:19:18 nia Exp $
$NetBSD: distinfo,v 1.5 2023/12/19 00:49:52 gutteridge Exp $
BLAKE2s (accountsservice-0.6.42.tar.xz) = 152d9309907b4e97780201f2f5a4c3237c0d173238cbe5aecea6bcae61cd11fa
SHA512 (accountsservice-0.6.42.tar.xz) = b31d77b88793a8264d32963a98ad446537292a134a3f80fabb4e2ce30f796e5f3066d02a27515c993133fa493b511a6abba6ff1a7827b5a54ea6a4f62a7b6fc9
Size (accountsservice-0.6.42.tar.xz) = 380500 bytes
SHA1 (patch-data_Makefile.am) = b059cd214a346adb371e4a006f497d652c9d9234
SHA1 (patch-src_daemon.c) = b39c9e4fe82b086002d760eb191de55ac791dc91
SHA1 (patch-src_libaccountsservice_act-user.c) = 50015cd0d4c32d1b97efa3620697790cca1db541
SHA1 (patch-src_user.c) = a55c2daf41a8c833de4af0517d353d3fcb73beff
SHA1 (patch-src_daemon.c) = 96de96d576a3d94f194d07dd97818a134eb68f0d
SHA1 (patch-src_libaccountsservice_act-user.c) = c7ddb6dd8ba776d40b185649e0777e1ec2d72634
SHA1 (patch-src_user.c) = db0b7bcf3746a984a0fea73bff6031939931a741
SHA1 (patch-src_util.c) = 1acd3a534e4c6c3892078f1e89456f732bbee813
SHA1 (patch-src_wtmp-helper.c) = eb32d598784f31e9baac44bd63ab248f5873c9c3

View File

@ -1,4 +1,4 @@
$NetBSD: patch-src_daemon.c,v 1.1 2018/06/11 23:55:50 youri Exp $
$NetBSD: patch-src_daemon.c,v 1.2 2023/12/19 00:49:52 gutteridge Exp $
Add NetBSD backend inspired from OpenBSD ports.
@ -32,7 +32,7 @@ Add NetBSD backend inspired from OpenBSD ports.
+/*
+ * Under NetBSD there is no /etc/login.defs (for USERGROUPS_ENAB), so
+ * we need to explicitely remove the user's group if it contains no more
+ * we need to explicitly remove the user's group if it contains no other
+ * members and matches the username.
+ */
+#ifdef __NetBSD__

View File

@ -1,18 +1,27 @@
$NetBSD: patch-src_libaccountsservice_act-user.c,v 1.1 2018/06/11 23:55:50 youri Exp $
$NetBSD: patch-src_libaccountsservice_act-user.c,v 1.2 2023/12/19 00:49:52 gutteridge Exp $
Add NetBSD backend.
--- src/libaccountsservice/act-user.c.orig 2018-05-25 23:09:35.000000000 +0000
--- src/libaccountsservice/act-user.c.orig 2016-01-11 15:42:43.000000000 +0000
+++ src/libaccountsservice/act-user.c
@@ -25,6 +25,7 @@
#include <sys/types.h>
@@ -20,9 +20,15 @@
#include <config.h>
+#include <sys/types.h>
+#ifdef __NetBSD__
+#include <err.h>
+#include <errno.h>
+#include <pwd.h>
+/* #include <util.h> XXX should be included, but this project has its own util.h! */
+#endif
#include <float.h>
#include <string.h>
-#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
+#include <errno.h>
#include <glib.h>
#include <glib/gi18n.h>
@@ -1818,8 +1819,29 @@ salt_char (GRand *rand)
@@ -1818,8 +1824,29 @@ salt_char (GRand *rand)
}
static gchar *
@ -22,9 +31,9 @@ Add NetBSD backend.
+#ifdef __NetBSD__
+ char salt[_PASSWORD_LEN+1];
+ char option[LINE_MAX], *key, *opt;
+ struct passwd *pw;
+ struct passwd *pw;
+
+ if (!(pw = getpwnam(username))) {
+ if (!(pw = getpwnam(username))) {
+ errx(EXIT_FAILURE, "can't get pw for %s", username);
+ }
+
@ -43,7 +52,7 @@ Add NetBSD backend.
GString *salt;
gchar *result;
GRand *rand;
@@ -1830,6 +1852,7 @@ make_crypted (const gchar *plain)
@@ -1830,6 +1857,7 @@ make_crypted (const gchar *plain)
/* SHA 256 */
g_string_append (salt, "$6$");
@ -51,7 +60,7 @@ Add NetBSD backend.
for (i = 0; i < 16; i++) {
g_string_append_c (salt, salt_char (rand));
}
@@ -1839,6 +1862,7 @@ make_crypted (const gchar *plain)
@@ -1839,6 +1867,7 @@ make_crypted (const gchar *plain)
g_string_free (salt, TRUE);
g_rand_free (rand);
@ -59,7 +68,7 @@ Add NetBSD backend.
return result;
}
@@ -1866,7 +1890,7 @@ act_user_set_password (ActUser
@@ -1866,7 +1895,7 @@ act_user_set_password (ActUser
g_return_if_fail (password != NULL);
g_return_if_fail (ACCOUNTS_IS_USER (user->accounts_proxy));

View File

@ -1,4 +1,4 @@
$NetBSD: patch-src_user.c,v 1.1 2018/06/11 23:55:50 youri Exp $
$NetBSD: patch-src_user.c,v 1.2 2023/12/19 00:49:52 gutteridge Exp $
Add NetBSD backend inspired from OpenBSD ports.
@ -27,7 +27,7 @@ Add NetBSD backend inspired from OpenBSD ports.
#ifdef HAVE_SHADOW_H
struct spwd *spent;
+#else
+ struct passwd *pw;
+ struct passwd *pw;
#endif
gchar *real_name;
gboolean changed;
@ -44,7 +44,7 @@ Add NetBSD backend inspired from OpenBSD ports.
+#endif
+
+
+/* On NetBSD, a locked account has it's password
+/* On NetBSD, a locked account has its password
+ * prepended by "*LOCKED*"
+ */
+#ifdef __NetBSD__
@ -60,7 +60,7 @@ Add NetBSD backend inspired from OpenBSD ports.
gboolean locked = GPOINTER_TO_INT (data);
GError *error;
+#ifdef __NetBSD__
+ const gchar *argv[6];
+ const gchar *argv[6];
+#else
const gchar *argv[5];
+#endif
@ -71,7 +71,7 @@ Add NetBSD backend inspired from OpenBSD ports.
locked ? "locking" : "unlocking", user->user_name, user->uid);
+#ifdef __NetBSD__
+ argv[0] = "/usr/sbin/usermod";
+ argv[1] = "-C";
+ argv[1] = "-C";
+ argv[2] = locked ? "yes" : "no";
+ argv[3] = "--";
+ argv[4] = user->user_name;
@ -126,7 +126,7 @@ Add NetBSD backend inspired from OpenBSD ports.
else if (user->locked) {
+#ifdef __NetBSD__
+ argv[0] = "/usr/sbin/usermod";
+ argv[1] = "-C";
+ argv[1] = "-C";
+ argv[2] = "no";
+ argv[3] = "--";
+ argv[4] = user->user_name;