Compare commits
59 changed files with 3507 additions and 4650 deletions
10
.gitignore
vendored
10
.gitignore
vendored
|
|
@ -16,13 +16,3 @@ shadow-4.1.4.2.tar.bz2
|
|||
/shadow-4.8.1.tar.xz.asc
|
||||
/shadow-4.9.tar.xz
|
||||
/shadow-4.9.tar.xz.asc
|
||||
/shadow-4.11.1.tar.xz
|
||||
/shadow-4.11.1.tar.xz.asc
|
||||
/shadow-4.12.3.tar.xz
|
||||
/shadow-4.12.3.tar.xz.asc
|
||||
/shadow-4.13.tar.xz
|
||||
/shadow-4.13.tar.xz.asc
|
||||
/shadow-4.14.0.tar.xz
|
||||
/shadow-4.14.0.tar.xz.asc
|
||||
/shadow-4.15.0.tar.xz
|
||||
/shadow-4.15.0.tar.xz.asc
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
# recipients: sssd-qe
|
||||
--- !Policy
|
||||
product_versions:
|
||||
- rhel-10
|
||||
- rhel-9
|
||||
decision_context: osci_compose_gate
|
||||
rules:
|
||||
- !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional}
|
||||
- !PassingTestCaseRule {test_case_name: baseos-ci.brew-build.tier1.functional}
|
||||
|
||||
|
|
|
|||
89
main.fmf
89
main.fmf
|
|
@ -1,10 +1,5 @@
|
|||
/plan:
|
||||
summary: Run shadow tests with pytest-mh (builder container)
|
||||
# Testing Farm automatically injects CI-built packages via artifact plugin
|
||||
# For GitLab MR: brew builds are installed via --how artifact --provide brew.build:<id>
|
||||
# For Packit PR: copr builds are installed automatically
|
||||
# Example for local testing with a specific build:
|
||||
# tmt run --all prepare --how artifact --provide brew.build:111005
|
||||
|
||||
provision:
|
||||
how: container
|
||||
|
|
@ -12,27 +7,13 @@
|
|||
|
||||
prepare:
|
||||
- name: Install base dependencies
|
||||
how: install
|
||||
package:
|
||||
- python3-pip
|
||||
- git
|
||||
- podman
|
||||
- hostname
|
||||
|
||||
- name: Upgrade pip
|
||||
how: shell
|
||||
script:
|
||||
- dnf install -y python3-pip git podman shadow-utils hostname
|
||||
- pip3 install --upgrade pip
|
||||
|
||||
- name: Clone shadow repository for tests
|
||||
how: shell
|
||||
script:
|
||||
- git clone https://github.com/shadow-maint/shadow.git /shadow
|
||||
|
||||
- name: Install Python dependencies on host
|
||||
how: shell
|
||||
script:
|
||||
- pip3 install -r /shadow/tests/system/requirements.txt
|
||||
- pip3 install pytest flaky jc
|
||||
- pip3 install git+https://github.com/next-actions/pytest-mh@1.0.21
|
||||
- pip3 install git+https://github.com/next-actions/pytest-ticket
|
||||
|
||||
- name: Start builder container
|
||||
how: shell
|
||||
|
|
@ -40,49 +21,14 @@
|
|||
- podman rm -f builder || true
|
||||
- podman run -d --name builder quay.io/centos/centos:stream10 sleep infinity
|
||||
|
||||
- name: Update builder container
|
||||
- name: Configure builder container
|
||||
how: shell
|
||||
script:
|
||||
- podman exec builder dnf update -y
|
||||
- podman exec builder dnf install -y util-linux expect
|
||||
|
||||
- name: Install shadow-utils into builder container from CI artifacts
|
||||
how: shell
|
||||
script:
|
||||
- |
|
||||
# Testing Farm artifact plugin installs CI-built RPMs in the HOST container
|
||||
# We need to copy those RPMs to the BUILDER container for testing
|
||||
|
||||
echo "=== Shadow-utils version in HOST container (from CI artifacts) ==="
|
||||
rpm -qa | grep shadow-utils
|
||||
echo "===================================================================="
|
||||
|
||||
# Download the same version RPMs that are installed in host
|
||||
HOST_VERSION=$(rpm -q shadow-utils --queryformat '%{VERSION}-%{RELEASE}')
|
||||
echo "Downloading shadow-utils version: ${HOST_VERSION} for builder container"
|
||||
|
||||
# Download all shadow-utils RPMs from host's repos/cache
|
||||
dnf download --destdir=/tmp shadow-utils-${HOST_VERSION} \
|
||||
shadow-utils-subid-${HOST_VERSION} 2>/dev/null || true
|
||||
|
||||
# Copy RPMs into builder container
|
||||
for rpm in /tmp/shadow-utils-*.rpm; do
|
||||
if [ -f "$rpm" ]; then
|
||||
podman cp "$rpm" builder:/tmp/
|
||||
fi
|
||||
done
|
||||
|
||||
# Install the RPMs in builder container
|
||||
podman exec builder bash -c 'dnf install -y /tmp/shadow-utils-*.rpm 2>/dev/null || dnf install -y shadow-utils'
|
||||
|
||||
echo "=== Shadow-utils version in BUILDER container (running tests) ==="
|
||||
podman exec builder rpm -qa | grep shadow-utils
|
||||
echo "===================================================================="
|
||||
|
||||
- name: Create CI user to simulate cloud VM environment
|
||||
how: shell
|
||||
script:
|
||||
- podman exec builder useradd ci
|
||||
- podman exec builder dnf install -y python3-pip git shadow-utils hostname
|
||||
- podman exec builder pip3 install --upgrade pip
|
||||
- podman exec builder pip3 install pytest flaky jc
|
||||
- podman exec builder pip3 install git+https://github.com/next-actions/pytest-mh@1.0.21
|
||||
- podman exec builder pip3 install git+https://github.com/next-actions/pytest-ticket
|
||||
|
||||
discover:
|
||||
how: fmf
|
||||
|
|
@ -91,13 +37,10 @@
|
|||
how: tmt
|
||||
|
||||
|
||||
/test:
|
||||
summary: Run system tests
|
||||
/ test:
|
||||
summary: Run user_add test
|
||||
test: |
|
||||
cd /shadow/tests/system
|
||||
|
||||
pytest --mh-config=mhc.yaml --mh-lazy-ssh -v \
|
||||
-k "not (test_chage and invalid_date) and \
|
||||
not (test_useradd and set_expire_date_with_invalid_date) and \
|
||||
not (test_usermod and set_expire_date_with_invalid_date)"
|
||||
duration: 30m
|
||||
git clone https://github.com/shadow-maint/shadow.git
|
||||
cd shadow/tests/system
|
||||
pytest --mh-config=mhc.yaml --mh-lazy-ssh -v
|
||||
duration: 30m
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
#%PAM-1.0
|
||||
# This tool only uses the password stack.
|
||||
password substack system-auth
|
||||
-password optional pam_gnome_keyring.so use_authtok
|
||||
password substack postlogin
|
||||
5
requirements.txt
Normal file
5
requirements.txt
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
flaky
|
||||
jc
|
||||
pytest
|
||||
git+https://github.com/next-actions/pytest-mh@1.0.21
|
||||
git+https://github.com/next-actions/pytest-ticket
|
||||
|
|
@ -1,441 +0,0 @@
|
|||
From 6974df39a708abf8bafbdfa2b7827e0f70f874cb Mon Sep 17 00:00:00 2001
|
||||
From: Serge Hallyn <serge@hallyn.com>
|
||||
Date: Mon, 6 Feb 2023 22:49:42 -0600
|
||||
Subject: [PATCH] newuidmap and newgidmap: support passing pid as fd
|
||||
|
||||
Closes #635
|
||||
|
||||
newuidmap and newgidmap currently take an integner pid as
|
||||
the first argument, determining the process id on which to
|
||||
act. Accept also "fd:N", where N must be an open file
|
||||
descriptor to the /proc/pid directory for the process to
|
||||
act upon. This way, if you
|
||||
|
||||
exec 10</proc/99
|
||||
newuidmap fd:10 100000 0 65536
|
||||
|
||||
and pid 99 dies and a new process happens to take pid 99 before
|
||||
newuidmap happens to do its work, then since newuidmap will use
|
||||
openat() using fd 10, it won't change the mapping for the new
|
||||
process.
|
||||
|
||||
Example:
|
||||
|
||||
// terminal 1:
|
||||
serge@jerom ~/src/nsexec$ ./nsexec -W -s 0 -S 0 -U
|
||||
about to unshare with 10000000
|
||||
Press any key to exec (I am 129176)
|
||||
|
||||
// terminal 2:
|
||||
serge@jerom ~/src/shadow$ exec 10</proc/129176
|
||||
serge@jerom ~/src/shadow$ sudo chown root src/newuidmap src/newgidmap
|
||||
serge@jerom ~/src/shadow$ sudo chmod u+s src/newuidmap
|
||||
serge@jerom ~/src/shadow$ sudo chmod u+s src/newgidmap
|
||||
serge@jerom ~/src/shadow$ ./src/newuidmap fd:10 0 100000 10
|
||||
serge@jerom ~/src/shadow$ ./src/newgidmap fd:10 0 100000 10
|
||||
|
||||
// Terminal 1:
|
||||
uid=0(root) gid=0(root) groups=0(root)
|
||||
|
||||
Signed-off-by: Serge Hallyn <serge@hallyn.com>
|
||||
---
|
||||
lib/get_pid.c | 51 +++++++++++++++++++++++++++++++++++++++++++++
|
||||
lib/prototypes.h | 2 ++
|
||||
man/newgidmap.1.xml | 11 ++++++++++
|
||||
man/newuidmap.1.xml | 11 ++++++++++
|
||||
src/newgidmap.c | 41 ++++++++++++++----------------------
|
||||
src/newuidmap.c | 40 +++++++++++++----------------------
|
||||
6 files changed, 106 insertions(+), 50 deletions(-)
|
||||
|
||||
diff --git a/lib/get_pid.c b/lib/get_pid.c
|
||||
index 10184bf0..ab91d158 100644
|
||||
--- a/lib/get_pid.c
|
||||
+++ b/lib/get_pid.c
|
||||
@@ -10,6 +10,9 @@
|
||||
|
||||
#include "prototypes.h"
|
||||
#include "defines.h"
|
||||
+#include <sys/types.h>
|
||||
+#include <sys/stat.h>
|
||||
+#include <fcntl.h>
|
||||
|
||||
int get_pid (const char *pidstr, pid_t *pid)
|
||||
{
|
||||
@@ -29,3 +32,51 @@ int get_pid (const char *pidstr, pid_t *pid)
|
||||
return 1;
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * If use passed in fd:4 as an argument, then return the
|
||||
+ * value '4', the fd to use.
|
||||
+ */
|
||||
+int get_pidfd_from_fd(const char *pidfdstr)
|
||||
+{
|
||||
+ long long int val;
|
||||
+ char *endptr;
|
||||
+
|
||||
+ errno = 0;
|
||||
+ val = strtoll (pidfdstr, &endptr, 10);
|
||||
+ if ( ('\0' == *pidfdstr)
|
||||
+ || ('\0' != *endptr)
|
||||
+ || (ERANGE == errno)
|
||||
+ || (/*@+longintegral@*/val != (pid_t)val)/*@=longintegral@*/) {
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ return (int)val;
|
||||
+}
|
||||
+
|
||||
+int open_pidfd(const char *pidstr)
|
||||
+{
|
||||
+ int proc_dir_fd;
|
||||
+ int written;
|
||||
+ char proc_dir_name[32];
|
||||
+ pid_t target;
|
||||
+
|
||||
+ if (get_pid(pidstr, &target) == 0)
|
||||
+ return -ENOENT;
|
||||
+
|
||||
+ /* max string length is 6 + 10 + 1 + 1 = 18, allocate 32 bytes */
|
||||
+ written = snprintf(proc_dir_name, sizeof(proc_dir_name), "/proc/%u/",
|
||||
+ target);
|
||||
+ if ((written <= 0) || ((size_t)written >= sizeof(proc_dir_name))) {
|
||||
+ fprintf(stderr, "snprintf of proc path failed for %u: %s\n",
|
||||
+ target, strerror(errno));
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+
|
||||
+ proc_dir_fd = open(proc_dir_name, O_DIRECTORY);
|
||||
+ if (proc_dir_fd < 0) {
|
||||
+ fprintf(stderr, _("Could not open proc directory for target %u: %s\n"),
|
||||
+ target, strerror(errno));
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+ return proc_dir_fd;
|
||||
+}
|
||||
diff --git a/lib/prototypes.h b/lib/prototypes.h
|
||||
index 400d5b97..21df6f61 100644
|
||||
--- a/lib/prototypes.h
|
||||
+++ b/lib/prototypes.h
|
||||
@@ -160,6 +160,8 @@ extern int getlong (const char *numstr, /*@out@*/long int *result);
|
||||
|
||||
/* get_pid.c */
|
||||
extern int get_pid (const char *pidstr, pid_t *pid);
|
||||
+extern int get_pidfd_from_fd(const char *pidfdstr);
|
||||
+extern int open_pidfd(const char *pidstr);
|
||||
|
||||
/* getrange */
|
||||
extern int getrange (const char *range,
|
||||
diff --git a/man/newgidmap.1.xml b/man/newgidmap.1.xml
|
||||
index e4ebc69e..9b7683eb 100644
|
||||
--- a/man/newgidmap.1.xml
|
||||
+++ b/man/newgidmap.1.xml
|
||||
@@ -116,6 +116,17 @@
|
||||
<para>
|
||||
Note that newgidmap may be used only once for a given process.
|
||||
</para>
|
||||
+ <para>
|
||||
+ Instead of an integer process id, the first argument may be
|
||||
+ specified as <replaceable>fd:N</replaceable>, where the integer N
|
||||
+ is the file descriptor number for the calling process's opened
|
||||
+ file for <filename>/proc/[pid[</filename>. In this case,
|
||||
+ <command>newgidmap</command> will use
|
||||
+ <refentrytitle>openat</refentrytitle><manvolnum>2</manvolnum>
|
||||
+ to open the <filename>gid_map</filename> file under that
|
||||
+ directory, avoiding a TOCTTOU in case the process exits and
|
||||
+ the pid is immediately reused.
|
||||
+ </para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
diff --git a/man/newuidmap.1.xml b/man/newuidmap.1.xml
|
||||
index f5cb5b48..ca917a77 100644
|
||||
--- a/man/newuidmap.1.xml
|
||||
+++ b/man/newuidmap.1.xml
|
||||
@@ -116,6 +116,17 @@
|
||||
<para>
|
||||
Note that newuidmap may be used only once for a given process.
|
||||
</para>
|
||||
+ <para>
|
||||
+ Instead of an integer process id, the first argument may be
|
||||
+ specified as <replaceable>fd:N</replaceable>, where the integer N
|
||||
+ is the file descriptor number for the calling process's opened
|
||||
+ file for <filename>/proc/[pid[</filename>. In this case,
|
||||
+ <command>newuidmap</command> will use
|
||||
+ <refentrytitle>openat</refentrytitle><manvolnum>2</manvolnum>
|
||||
+ to open the <filename>uid_map</filename> file under that
|
||||
+ directory, avoiding a TOCTTOU in case the process exits and
|
||||
+ the pid is immediately reused.
|
||||
+ </para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 id='options'>
|
||||
diff --git a/src/newgidmap.c b/src/newgidmap.c
|
||||
index 01d0fe90..d6d29725 100644
|
||||
--- a/src/newgidmap.c
|
||||
+++ b/src/newgidmap.c
|
||||
@@ -69,7 +69,7 @@ static void verify_ranges(struct passwd *pw, int ranges,
|
||||
|
||||
static void usage(void)
|
||||
{
|
||||
- fprintf(stderr, _("usage: %s <pid> <gid> <lowergid> <count> [ <gid> <lowergid> <count> ] ... \n"), Prog);
|
||||
+ fprintf(stderr, _("usage: %s [<pid|fd:<pidfd>] <gid> <lowergid> <count> [ <gid> <lowergid> <count> ] ... \n"), Prog);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -143,15 +143,12 @@ out:
|
||||
*/
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
- char proc_dir_name[32];
|
||||
char *target_str;
|
||||
- pid_t target;
|
||||
int proc_dir_fd;
|
||||
int ranges;
|
||||
struct map_range *mappings;
|
||||
struct stat st;
|
||||
struct passwd *pw;
|
||||
- int written;
|
||||
bool allow_setgroups = false;
|
||||
|
||||
Prog = Basename (argv[0]);
|
||||
@@ -168,25 +165,19 @@ int main(int argc, char **argv)
|
||||
/* Find the process that needs its user namespace
|
||||
* gid mapping set.
|
||||
*/
|
||||
- target_str = argv[1];
|
||||
- if (!get_pid(target_str, &target))
|
||||
- usage();
|
||||
|
||||
- /* max string length is 6 + 10 + 1 + 1 = 18, allocate 32 bytes */
|
||||
- written = snprintf(proc_dir_name, sizeof(proc_dir_name), "/proc/%u/",
|
||||
- target);
|
||||
- if ((written <= 0) || (written >= sizeof(proc_dir_name))) {
|
||||
- fprintf(stderr, "%s: snprintf of proc path failed: %s\n",
|
||||
- Prog, strerror(errno));
|
||||
- }
|
||||
-
|
||||
- proc_dir_fd = open(proc_dir_name, O_DIRECTORY);
|
||||
- if (proc_dir_fd < 0) {
|
||||
- fprintf(stderr, _("%s: Could not open proc directory for target %u\n"),
|
||||
- Prog, target);
|
||||
- return EXIT_FAILURE;
|
||||
+ target_str = argv[1];
|
||||
+ if (strlen(target_str) > 3 && strncmp(target_str, "fd:", 3) == 0) {
|
||||
+ /* the user passed in a /proc/pid fd for the process */
|
||||
+ target_str = &target_str[3];
|
||||
+ proc_dir_fd = get_pidfd_from_fd(target_str);
|
||||
+ if (proc_dir_fd < 0)
|
||||
+ usage();
|
||||
+ } else {
|
||||
+ proc_dir_fd = open_pidfd(target_str);
|
||||
+ if (proc_dir_fd < 0)
|
||||
+ usage();
|
||||
}
|
||||
-
|
||||
/* Who am i? */
|
||||
pw = get_my_pwent ();
|
||||
if (NULL == pw) {
|
||||
@@ -200,8 +191,8 @@ int main(int argc, char **argv)
|
||||
|
||||
/* Get the effective uid and effective gid of the target process */
|
||||
if (fstat(proc_dir_fd, &st) < 0) {
|
||||
- fprintf(stderr, _("%s: Could not stat directory for target %u\n"),
|
||||
- Prog, target);
|
||||
+ fprintf(stderr, _("%s: Could not stat directory for process\n"),
|
||||
+ Prog);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
@@ -213,8 +204,8 @@ int main(int argc, char **argv)
|
||||
(!getdef_bool("GRANT_AUX_GROUP_SUBIDS") && (getgid() != pw->pw_gid)) ||
|
||||
(pw->pw_uid != st.st_uid) ||
|
||||
(getgid() != st.st_gid)) {
|
||||
- fprintf(stderr, _( "%s: Target %u is owned by a different user: uid:%lu pw_uid:%lu st_uid:%lu, gid:%lu pw_gid:%lu st_gid:%lu\n" ),
|
||||
- Prog, target,
|
||||
+ fprintf(stderr, _( "%s: Target process is owned by a different user: uid:%lu pw_uid:%lu st_uid:%lu, gid:%lu pw_gid:%lu st_gid:%lu\n" ),
|
||||
+ Prog,
|
||||
(unsigned long int)getuid(), (unsigned long int)pw->pw_uid, (unsigned long int)st.st_uid,
|
||||
(unsigned long int)getgid(), (unsigned long int)pw->pw_gid, (unsigned long int)st.st_gid);
|
||||
return EXIT_FAILURE;
|
||||
diff --git a/src/newuidmap.c b/src/newuidmap.c
|
||||
index e8798409..e99655c9 100644
|
||||
--- a/src/newuidmap.c
|
||||
+++ b/src/newuidmap.c
|
||||
@@ -64,7 +64,7 @@ static void verify_ranges(struct passwd *pw, int ranges,
|
||||
|
||||
static void usage(void)
|
||||
{
|
||||
- fprintf(stderr, _("usage: %s <pid> <uid> <loweruid> <count> [ <uid> <loweruid> <count> ] ... \n"), Prog);
|
||||
+ fprintf(stderr, _("usage: %s [<pid>|fd:<pidfd>] <uid> <loweruid> <count> [ <uid> <loweruid> <count> ] ... \n"), Prog);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -73,15 +73,12 @@ static void usage(void)
|
||||
*/
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
- char proc_dir_name[32];
|
||||
char *target_str;
|
||||
- pid_t target;
|
||||
int proc_dir_fd;
|
||||
int ranges;
|
||||
struct map_range *mappings;
|
||||
struct stat st;
|
||||
struct passwd *pw;
|
||||
- int written;
|
||||
|
||||
Prog = Basename (argv[0]);
|
||||
log_set_progname(Prog);
|
||||
@@ -94,26 +91,20 @@ int main(int argc, char **argv)
|
||||
if (argc < 2)
|
||||
usage();
|
||||
|
||||
+ target_str = argv[1];
|
||||
/* Find the process that needs its user namespace
|
||||
* uid mapping set.
|
||||
*/
|
||||
- target_str = argv[1];
|
||||
- if (!get_pid(target_str, &target))
|
||||
- usage();
|
||||
-
|
||||
- /* max string length is 6 + 10 + 1 + 1 = 18, allocate 32 bytes */
|
||||
- written = snprintf(proc_dir_name, sizeof(proc_dir_name), "/proc/%u/",
|
||||
- target);
|
||||
- if ((written <= 0) || (written >= sizeof(proc_dir_name))) {
|
||||
- fprintf(stderr, "%s: snprintf of proc path failed: %s\n",
|
||||
- Prog, strerror(errno));
|
||||
- }
|
||||
-
|
||||
- proc_dir_fd = open(proc_dir_name, O_DIRECTORY);
|
||||
- if (proc_dir_fd < 0) {
|
||||
- fprintf(stderr, _("%s: Could not open proc directory for target %u\n"),
|
||||
- Prog, target);
|
||||
- return EXIT_FAILURE;
|
||||
+ if (strlen(target_str) > 3 && strncmp(target_str, "fd:", 3) == 0) {
|
||||
+ /* the user passed in a /proc/pid fd for the process */
|
||||
+ target_str = &target_str[3];
|
||||
+ proc_dir_fd = get_pidfd_from_fd(target_str);
|
||||
+ if (proc_dir_fd < 0)
|
||||
+ usage();
|
||||
+ } else {
|
||||
+ proc_dir_fd = open_pidfd(target_str);
|
||||
+ if (proc_dir_fd < 0)
|
||||
+ usage();
|
||||
}
|
||||
|
||||
/* Who am i? */
|
||||
@@ -129,8 +120,7 @@ int main(int argc, char **argv)
|
||||
|
||||
/* Get the effective uid and effective gid of the target process */
|
||||
if (fstat(proc_dir_fd, &st) < 0) {
|
||||
- fprintf(stderr, _("%s: Could not stat directory for target %u\n"),
|
||||
- Prog, target);
|
||||
+ fprintf(stderr, _("%s: Could not stat directory for target process\n"), Prog);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
@@ -142,8 +132,8 @@ int main(int argc, char **argv)
|
||||
(!getdef_bool("GRANT_AUX_GROUP_SUBIDS") && (getgid() != pw->pw_gid)) ||
|
||||
(pw->pw_uid != st.st_uid) ||
|
||||
(getgid() != st.st_gid)) {
|
||||
- fprintf(stderr, _( "%s: Target process %u is owned by a different user: uid:%lu pw_uid:%lu st_uid:%lu, gid:%lu pw_gid:%lu st_gid:%lu\n" ),
|
||||
- Prog, target,
|
||||
+ fprintf(stderr, _( "%s: Target process is owned by a different user: uid:%lu pw_uid:%lu st_uid:%lu, gid:%lu pw_gid:%lu st_gid:%lu\n" ),
|
||||
+ Prog,
|
||||
(unsigned long int)getuid(), (unsigned long int)pw->pw_uid, (unsigned long int)st.st_uid,
|
||||
(unsigned long int)getgid(), (unsigned long int)pw->pw_gid, (unsigned long int)st.st_gid);
|
||||
return EXIT_FAILURE;
|
||||
--
|
||||
2.39.2
|
||||
|
||||
From 7ff33fae6f9cd79c0e012671c37a172e9a681d0b Mon Sep 17 00:00:00 2001
|
||||
From: Serge Hallyn <serge@hallyn.com>
|
||||
Date: Fri, 24 Feb 2023 13:52:32 -0600
|
||||
Subject: [PATCH] get_pidfd_from_fd: return -1 on error, not 0
|
||||
|
||||
Fixes: 6974df39a: newuidmap and newgidmap: support passing pid as fd
|
||||
Signed-off-by: Serge Hallyn <serge@hallyn.com>
|
||||
---
|
||||
lib/get_pid.c | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/lib/get_pid.c b/lib/get_pid.c
|
||||
index ab91d158..5b6d9da4 100644
|
||||
--- a/lib/get_pid.c
|
||||
+++ b/lib/get_pid.c
|
||||
@@ -35,6 +35,7 @@ int get_pid (const char *pidstr, pid_t *pid)
|
||||
/*
|
||||
* If use passed in fd:4 as an argument, then return the
|
||||
* value '4', the fd to use.
|
||||
+ * On error, return -1.
|
||||
*/
|
||||
int get_pidfd_from_fd(const char *pidfdstr)
|
||||
{
|
||||
@@ -47,7 +48,7 @@ int get_pidfd_from_fd(const char *pidfdstr)
|
||||
|| ('\0' != *endptr)
|
||||
|| (ERANGE == errno)
|
||||
|| (/*@+longintegral@*/val != (pid_t)val)/*@=longintegral@*/) {
|
||||
- return 0;
|
||||
+ return -1;
|
||||
}
|
||||
|
||||
return (int)val;
|
||||
--
|
||||
2.39.2
|
||||
|
||||
From 05e2adf509ba0e3779dae66a276b86927a8e1e0e Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Vin=C3=ADcius=20dos=20Santos=20Oliveira?=
|
||||
<vini.ipsmaker@gmail.com>
|
||||
Date: Fri, 24 Feb 2023 18:06:02 -0300
|
||||
Subject: [PATCH] Validate fds created by the user
|
||||
|
||||
write_mapping() will do the following:
|
||||
|
||||
openat(proc_dir_fd, map_file, O_WRONLY);
|
||||
|
||||
An attacker could create a directory containing a symlink named
|
||||
"uid_map" pointing to any file owned by root, and thus allow him to
|
||||
overwrite any root-owned file.
|
||||
---
|
||||
lib/get_pid.c | 17 +++++++++++++++++
|
||||
1 file changed, 17 insertions(+)
|
||||
|
||||
diff --git a/lib/get_pid.c b/lib/get_pid.c
|
||||
index 5b6d9da4..8e5e6014 100644
|
||||
--- a/lib/get_pid.c
|
||||
+++ b/lib/get_pid.c
|
||||
@@ -41,6 +41,8 @@ int get_pidfd_from_fd(const char *pidfdstr)
|
||||
{
|
||||
long long int val;
|
||||
char *endptr;
|
||||
+ struct stat st;
|
||||
+ dev_t proc_st_dev, proc_st_rdev;
|
||||
|
||||
errno = 0;
|
||||
val = strtoll (pidfdstr, &endptr, 10);
|
||||
@@ -51,6 +53,21 @@ int get_pidfd_from_fd(const char *pidfdstr)
|
||||
return -1;
|
||||
}
|
||||
|
||||
+ if (stat("/proc/self/uid_map", &st) < 0) {
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ proc_st_dev = st.st_dev;
|
||||
+ proc_st_rdev = st.st_rdev;
|
||||
+
|
||||
+ if (fstat(val, &st) < 0) {
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ if (st.st_dev != proc_st_dev || st.st_rdev != proc_st_rdev) {
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
return (int)val;
|
||||
}
|
||||
|
||||
--
|
||||
2.39.2
|
||||
|
||||
|
|
@ -1,288 +0,0 @@
|
|||
diff -up shadow-4.14.0/libmisc/agetpass.c.orig shadow-4.14.0/libmisc/agetpass.c
|
||||
--- shadow-4.14.0/libmisc/agetpass.c.orig 2024-01-24 20:06:20.557577853 +0100
|
||||
+++ shadow-4.14.0/libmisc/agetpass.c 2024-01-24 21:21:06.379445080 +0100
|
||||
@@ -32,6 +32,7 @@
|
||||
* SYNOPSIS
|
||||
* [[gnu::malloc(erase_pass)]]
|
||||
* char *agetpass(const char *prompt);
|
||||
+ * char *agetpass_stdin();
|
||||
*
|
||||
* void erase_pass(char *pass);
|
||||
*
|
||||
@@ -64,6 +65,10 @@
|
||||
* erased by calling erase_pass(), to avoid possibly leaking the
|
||||
* password.
|
||||
*
|
||||
+ * agetpass_stdin()
|
||||
+ * This function is the same as previous one (agetpass). Just the
|
||||
+ * password is read from stdin and terminal is not required.
|
||||
+ *
|
||||
* erase_pass()
|
||||
* This function first clears the password, by calling
|
||||
* explicit_bzero(3) (or an equivalent call), and then frees the
|
||||
@@ -92,8 +97,8 @@
|
||||
*/
|
||||
|
||||
|
||||
-char *
|
||||
-agetpass(const char *prompt)
|
||||
+static char *
|
||||
+agetpass_internal(const char *prompt, int flags)
|
||||
{
|
||||
char *pass;
|
||||
size_t len;
|
||||
@@ -110,7 +115,7 @@ agetpass(const char *prompt)
|
||||
if (pass == NULL)
|
||||
return NULL;
|
||||
|
||||
- if (readpassphrase(prompt, pass, PASS_MAX + 2, RPP_REQUIRE_TTY) == NULL)
|
||||
+ if (readpassphrase(prompt, pass, PASS_MAX + 2, flags) == NULL)
|
||||
goto fail;
|
||||
|
||||
len = strlen(pass);
|
||||
@@ -126,6 +131,17 @@ fail:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
+char *
|
||||
+agetpass(const char *prompt)
|
||||
+{
|
||||
+ return agetpass_internal(prompt, RPP_REQUIRE_TTY);
|
||||
+}
|
||||
+
|
||||
+char *
|
||||
+agetpass_stdin()
|
||||
+{
|
||||
+ return agetpass_internal(NULL, RPP_STDIN);
|
||||
+}
|
||||
|
||||
void
|
||||
erase_pass(char *pass)
|
||||
diff -up shadow-4.14.0/lib/prototypes.h.orig shadow-4.14.0/lib/prototypes.h
|
||||
--- shadow-4.14.0/lib/prototypes.h.orig 2024-01-24 22:06:18.786184942 +0100
|
||||
+++ shadow-4.14.0/lib/prototypes.h 2024-01-24 20:19:45.299231059 +0100
|
||||
@@ -47,6 +47,7 @@ extern int expire (const struct passwd *
|
||||
extern void erase_pass(char *pass);
|
||||
ATTR_MALLOC(erase_pass)
|
||||
extern char *agetpass(const char *prompt);
|
||||
+extern char *agetpass_stdin();
|
||||
|
||||
/* isexpired.c */
|
||||
extern int isexpired (const struct passwd *, /*@null@*/const struct spwd *);
|
||||
diff -up shadow-4.14.0/man/passwd.1.xml.orig shadow-4.14.0/man/passwd.1.xml
|
||||
--- shadow-4.14.0/man/passwd.1.xml.orig 2024-01-24 20:33:31.438972506 +0100
|
||||
+++ shadow-4.14.0/man/passwd.1.xml 2024-01-29 17:36:31.082495245 +0100
|
||||
@@ -341,6 +341,17 @@
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
+ <varlistentry>
|
||||
+ <term>
|
||||
+ <option>-s</option>, <option>--stdin</option>
|
||||
+ </term>
|
||||
+ <listitem>
|
||||
+ <para>
|
||||
+ This option is used to indicate that passwd should read the new password from standard
|
||||
+ input, which can be a pipe.
|
||||
+ </para>
|
||||
+ </listitem>
|
||||
+ </varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
diff -up shadow-4.14.0/src/passwd.c.orig shadow-4.14.0/src/passwd.c
|
||||
--- shadow-4.14.0/src/passwd.c.orig 2024-01-24 13:57:15.714549266 +0100
|
||||
+++ shadow-4.14.0/src/passwd.c 2024-01-29 17:33:59.421508534 +0100
|
||||
@@ -65,7 +65,8 @@ static bool
|
||||
Sflg = false, /* -S - show password status */
|
||||
uflg = false, /* -u - unlock the user's password */
|
||||
wflg = false, /* -w - set warning days */
|
||||
- xflg = false; /* -x - set maximum days */
|
||||
+ xflg = false, /* -x - set maximum days */
|
||||
+ sflg = false; /* -s - read passwd from stdin */
|
||||
|
||||
/*
|
||||
* set to 1 if there are any flags which require root privileges,
|
||||
@@ -156,6 +157,7 @@ usage (int status)
|
||||
(void) fputs (_(" -w, --warndays WARN_DAYS set expiration warning days to WARN_DAYS\n"), usageout);
|
||||
(void) fputs (_(" -x, --maxdays MAX_DAYS set maximum number of days before password\n"
|
||||
" change to MAX_DAYS\n"), usageout);
|
||||
+ (void) fputs (_(" -s, --stdin read new token from stdin\n"), usageout);
|
||||
(void) fputs ("\n", usageout);
|
||||
exit (status);
|
||||
}
|
||||
@@ -275,7 +277,7 @@ static int new_password (const struct pa
|
||||
pass_max_len = getdef_num ("PASS_MAX_LEN", 8);
|
||||
}
|
||||
}
|
||||
- if (!qflg) {
|
||||
+ if (!qflg && !sflg) {
|
||||
if (pass_max_len == -1) {
|
||||
(void) printf (_(
|
||||
"Enter the new password (minimum of %d characters)\n"
|
||||
@@ -289,55 +291,67 @@ static int new_password (const struct pa
|
||||
}
|
||||
}
|
||||
|
||||
- warned = false;
|
||||
- for (i = getdef_num ("PASS_CHANGE_TRIES", 5); i > 0; i--) {
|
||||
- cp = agetpass (_("New password: "));
|
||||
+ if (sflg) {
|
||||
+ /*
|
||||
+ * root is setting the passphrase from stdin
|
||||
+ */
|
||||
+ cp = agetpass_stdin ();
|
||||
if (NULL == cp) {
|
||||
- memzero (orig, sizeof orig);
|
||||
- memzero (pass, sizeof pass);
|
||||
return -1;
|
||||
}
|
||||
- if (warned && (strcmp (pass, cp) != 0)) {
|
||||
- warned = false;
|
||||
- }
|
||||
STRFCPY (pass, cp);
|
||||
erase_pass (cp);
|
||||
+ } else {
|
||||
+ warned = false;
|
||||
+ for (i = getdef_num ("PASS_CHANGE_TRIES", 5); i > 0; i--) {
|
||||
+ cp = agetpass (_("New password: "));
|
||||
+ if (NULL == cp) {
|
||||
+ memzero (orig, sizeof orig);
|
||||
+ memzero (pass, sizeof pass);
|
||||
+ return -1;
|
||||
+ }
|
||||
+ if (warned && (strcmp (pass, cp) != 0)) {
|
||||
+ warned = false;
|
||||
+ }
|
||||
+ STRFCPY (pass, cp);
|
||||
+ erase_pass (cp);
|
||||
|
||||
- if (!amroot && !obscure(orig, pass, pw)) {
|
||||
- (void) puts (_("Try again."));
|
||||
- continue;
|
||||
- }
|
||||
+ if (!amroot && !obscure(orig, pass, pw)) {
|
||||
+ (void) puts (_("Try again."));
|
||||
+ continue;
|
||||
+ }
|
||||
|
||||
- /*
|
||||
- * If enabled, warn about weak passwords even if you are
|
||||
- * root (enter this password again to use it anyway).
|
||||
- * --marekm
|
||||
- */
|
||||
- if (amroot && !warned && getdef_bool ("PASS_ALWAYS_WARN")
|
||||
- && !obscure(orig, pass, pw)) {
|
||||
- (void) puts (_("\nWarning: weak password (enter it again to use it anyway)."));
|
||||
- warned = true;
|
||||
- continue;
|
||||
+ /*
|
||||
+ * If enabled, warn about weak passwords even if you are
|
||||
+ * root (enter this password again to use it anyway).
|
||||
+ * --marekm
|
||||
+ */
|
||||
+ if (amroot && !warned && getdef_bool ("PASS_ALWAYS_WARN")
|
||||
+ && !obscure(orig, pass, pw)) {
|
||||
+ (void) puts (_("\nWarning: weak password (enter it again to use it anyway)."));
|
||||
+ warned = true;
|
||||
+ continue;
|
||||
+ }
|
||||
+ cp = agetpass (_("Re-enter new password: "));
|
||||
+ if (NULL == cp) {
|
||||
+ memzero (orig, sizeof orig);
|
||||
+ memzero (pass, sizeof pass);
|
||||
+ return -1;
|
||||
+ }
|
||||
+ if (strcmp (cp, pass) != 0) {
|
||||
+ erase_pass (cp);
|
||||
+ (void) fputs (_("They don't match; try again.\n"), stderr);
|
||||
+ } else {
|
||||
+ erase_pass (cp);
|
||||
+ break;
|
||||
+ }
|
||||
}
|
||||
- cp = agetpass (_("Re-enter new password: "));
|
||||
- if (NULL == cp) {
|
||||
- memzero (orig, sizeof orig);
|
||||
+ memzero (orig, sizeof orig);
|
||||
+
|
||||
+ if (i == 0) {
|
||||
memzero (pass, sizeof pass);
|
||||
return -1;
|
||||
}
|
||||
- if (strcmp (cp, pass) != 0) {
|
||||
- erase_pass (cp);
|
||||
- (void) fputs (_("They don't match; try again.\n"), stderr);
|
||||
- } else {
|
||||
- erase_pass (cp);
|
||||
- break;
|
||||
- }
|
||||
- }
|
||||
- memzero (orig, sizeof orig);
|
||||
-
|
||||
- if (i == 0) {
|
||||
- memzero (pass, sizeof pass);
|
||||
- return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -714,6 +728,7 @@ static void update_shadow (void)
|
||||
* -u unlock the password of the named account (*)
|
||||
* -w # set sp_warn to # days (*)
|
||||
* -x # set sp_max to # days (*)
|
||||
+ * -s read password from stdin
|
||||
*
|
||||
* (*) requires root permission to execute.
|
||||
*
|
||||
@@ -781,10 +796,11 @@ int main (int argc, char **argv)
|
||||
{"unlock", no_argument, NULL, 'u'},
|
||||
{"warndays", required_argument, NULL, 'w'},
|
||||
{"maxdays", required_argument, NULL, 'x'},
|
||||
+ {"stdin", no_argument, NULL, 's'},
|
||||
{NULL, 0, NULL, '\0'}
|
||||
};
|
||||
|
||||
- while ((c = getopt_long (argc, argv, "adehi:kln:qr:R:P:Suw:x:",
|
||||
+ while ((c = getopt_long (argc, argv, "adehi:kln:qr:R:P:Suw:x:s",
|
||||
long_options, NULL)) != -1) {
|
||||
switch (c) {
|
||||
case 'a':
|
||||
@@ -877,6 +893,15 @@ int main (int argc, char **argv)
|
||||
xflg = true;
|
||||
anyflag = true;
|
||||
break;
|
||||
+ case 's':
|
||||
+ if (!amroot) {
|
||||
+ (void) fprintf (stderr,
|
||||
+ _("%s: only root can use --stdin/-s option\n"),
|
||||
+ Prog);
|
||||
+ usage (E_BAD_ARG);
|
||||
+ }
|
||||
+ sflg = true;
|
||||
+ break;
|
||||
default:
|
||||
usage (E_BAD_ARG);
|
||||
}
|
||||
@@ -1068,7 +1093,16 @@ int main (int argc, char **argv)
|
||||
* Don't set the real UID for PAM...
|
||||
*/
|
||||
if (!anyflag && use_pam) {
|
||||
- do_pam_passwd (name, qflg, kflg);
|
||||
+ if (sflg) {
|
||||
+ cp = agetpass_stdin ();
|
||||
+ if (cp == NULL) {
|
||||
+ exit (E_FAILURE);
|
||||
+ }
|
||||
+ do_pam_passwd_non_interactive ("passwd", name, cp);
|
||||
+ erase_pass (cp);
|
||||
+ } else {
|
||||
+ do_pam_passwd (name, qflg, kflg);
|
||||
+ }
|
||||
exit (E_SUCCESS);
|
||||
}
|
||||
#endif /* USE_PAM */
|
||||
@@ -1102,4 +1136,3 @@ int main (int argc, char **argv)
|
||||
|
||||
return E_SUCCESS;
|
||||
}
|
||||
-
|
||||
|
|
@ -1,306 +0,0 @@
|
|||
From 43b4e5a6c41f5c43cad18810f9229e40e8c4a57e Mon Sep 17 00:00:00 2001
|
||||
From: Alejandro Colomar <alx@kernel.org>
|
||||
Date: Mon, 30 Oct 2023 12:53:37 +0100
|
||||
Subject: [PATCH 1/2] Remove FascistHistory() and FascistHistoryPw() calls
|
||||
|
||||
These functions don't seem to exist anymore. I can't find them in
|
||||
Debian, nor in a web search. They probably were functions from an
|
||||
ancient implementation of cracklib that doesn't exist anymore.
|
||||
|
||||
$ git remote -v
|
||||
origin git@github.com:cracklib/cracklib.git (fetch)
|
||||
origin git@github.com:cracklib/cracklib.git (push)
|
||||
$ grep -rni fascisthistory
|
||||
$ git log --grep FascistHistory
|
||||
$ git log -S FascistHistory
|
||||
|
||||
Closes: <https://codesearch.debian.net/search?q=FascistHistory&literal=1>
|
||||
Cc: Mike Frysinger <vapier@gentoo.org>
|
||||
Acked-by: Michael Vetter <jubalh@iodoru.org>
|
||||
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
||||
---
|
||||
configure.ac | 4 ----
|
||||
libmisc/obscure.c | 8 --------
|
||||
src/passwd.c | 33 ++-------------------------------
|
||||
3 files changed, 2 insertions(+), 43 deletions(-)
|
||||
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index 2c8cca3f..5c8c7764 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -526,10 +526,6 @@ if test "$with_libcrack" = "yes"; then
|
||||
echo "checking cracklib flavour, don't be surprised by the results"
|
||||
AC_CHECK_LIB(crack, FascistCheck,
|
||||
[LIBCRACK=-lcrack AC_DEFINE(HAVE_LIBCRACK, 1, [Defined if you have libcrack.])])
|
||||
- AC_CHECK_LIB(crack, FascistHistory,
|
||||
- AC_DEFINE(HAVE_LIBCRACK_HIST, 1, [Defined if you have the ts&szs cracklib.]))
|
||||
- AC_CHECK_LIB(crack, FascistHistoryPw,
|
||||
- AC_DEFINE(HAVE_LIBCRACK_PW, 1, [Defined if it includes *Pw functions.]))
|
||||
fi
|
||||
|
||||
if test "$with_btrfs" != "no"; then
|
||||
diff --git a/libmisc/obscure.c b/libmisc/obscure.c
|
||||
index ccffb71d..4070d4e4 100644
|
||||
--- a/libmisc/obscure.c
|
||||
+++ b/libmisc/obscure.c
|
||||
@@ -100,11 +100,7 @@ static /*@observer@*//*@null@*/const char *password_check (
|
||||
#ifdef HAVE_LIBCRACK
|
||||
char *dictpath;
|
||||
|
||||
-#ifdef HAVE_LIBCRACK_PW
|
||||
- char *FascistCheckPw ();
|
||||
-#else
|
||||
char *FascistCheck ();
|
||||
-#endif
|
||||
#endif
|
||||
|
||||
if (strcmp (new, old) == 0) {
|
||||
@@ -133,11 +129,7 @@ static /*@observer@*//*@null@*/const char *password_check (
|
||||
|
||||
dictpath = getdef_str ("CRACKLIB_DICTPATH");
|
||||
if (NULL != dictpath) {
|
||||
-#ifdef HAVE_LIBCRACK_PW
|
||||
- msg = FascistCheckPw (new, dictpath, pwdp);
|
||||
-#else
|
||||
msg = FascistCheck (new, dictpath);
|
||||
-#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
diff --git a/src/passwd.c b/src/passwd.c
|
||||
index 67608619..a4f49320 100644
|
||||
--- a/src/passwd.c
|
||||
+++ b/src/passwd.c
|
||||
@@ -114,7 +114,6 @@ static bool do_update_pwd = false;
|
||||
/* local function prototypes */
|
||||
NORETURN static void usage (int);
|
||||
|
||||
-static bool reuse (const char *, const struct passwd *);
|
||||
static int new_password (const struct passwd *);
|
||||
|
||||
static void check_password (const struct passwd *, const struct spwd *);
|
||||
@@ -163,27 +162,6 @@ usage (int status)
|
||||
exit (status);
|
||||
}
|
||||
|
||||
-static bool reuse (const char *pass, const struct passwd *pw)
|
||||
-{
|
||||
-#ifdef HAVE_LIBCRACK_HIST
|
||||
- const char *reason;
|
||||
-
|
||||
-#ifdef HAVE_LIBCRACK_PW
|
||||
- const char *FascistHistoryPw (const char *, const struct passwd *);
|
||||
-
|
||||
- reason = FascistHistory (pass, pw);
|
||||
-#else /* !HAVE_LIBCRACK_PW */
|
||||
- const char *FascistHistory (const char *, int);
|
||||
-
|
||||
- reason = FascistHistory (pass, pw->pw_uid);
|
||||
-#endif /* !HAVE_LIBCRACK_PW */
|
||||
- if (NULL != reason) {
|
||||
- (void) printf (_("Bad password: %s. "), reason);
|
||||
- return true;
|
||||
- }
|
||||
-#endif /* HAVE_LIBCRACK_HIST */
|
||||
- return false;
|
||||
-}
|
||||
|
||||
/*
|
||||
* new_password - validate old password and replace with new (both old and
|
||||
@@ -202,10 +180,6 @@ static int new_password (const struct passwd *pw)
|
||||
int pass_max_len = -1;
|
||||
const char *method;
|
||||
|
||||
-#ifdef HAVE_LIBCRACK_HIST
|
||||
- int HistUpdate (const char *, const char *);
|
||||
-#endif /* HAVE_LIBCRACK_HIST */
|
||||
-
|
||||
/*
|
||||
* Authenticate the user. The user will be prompted for their own
|
||||
* password.
|
||||
@@ -306,7 +280,7 @@ static int new_password (const struct passwd *pw)
|
||||
STRFCPY (pass, cp);
|
||||
erase_pass (cp);
|
||||
|
||||
- if (!amroot && (!obscure (orig, pass, pw) || reuse (pass, pw))) {
|
||||
+ if (!amroot && !obscure(orig, pass, pw)) {
|
||||
(void) puts (_("Try again."));
|
||||
continue;
|
||||
}
|
||||
@@ -317,7 +291,7 @@ static int new_password (const struct passwd *pw)
|
||||
* --marekm
|
||||
*/
|
||||
if (amroot && !warned && getdef_bool ("PASS_ALWAYS_WARN")
|
||||
- && (!obscure (orig, pass, pw) || reuse (pass, pw))) {
|
||||
+ && !obscure(orig, pass, pw)) {
|
||||
(void) puts (_("\nWarning: weak password (enter it again to use it anyway)."));
|
||||
warned = true;
|
||||
continue;
|
||||
@@ -357,9 +331,6 @@ static int new_password (const struct passwd *pw)
|
||||
return -1;
|
||||
}
|
||||
|
||||
-#ifdef HAVE_LIBCRACK_HIST
|
||||
- HistUpdate (pw->pw_name, crypt_passwd);
|
||||
-#endif /* HAVE_LIBCRACK_HIST */
|
||||
STRFCPY (crypt_passwd, cp);
|
||||
return 0;
|
||||
}
|
||||
--
|
||||
2.43.0
|
||||
|
||||
|
||||
From 45f34ee8c196a98397504cb7ed8576b6f1825cf9 Mon Sep 17 00:00:00 2001
|
||||
From: Alejandro Colomar <alx@kernel.org>
|
||||
Date: Mon, 30 Oct 2023 13:31:42 +0100
|
||||
Subject: [PATCH 2/2] Remove libcrack support
|
||||
|
||||
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
||||
---
|
||||
configure.ac | 11 -----------
|
||||
etc/login.defs | 5 -----
|
||||
lib/getdef.c | 1 -
|
||||
libmisc/obscure.c | 22 ----------------------
|
||||
libsubid/Makefile.am | 1 -
|
||||
src/Makefile.am | 2 +-
|
||||
7 files changed, 2 insertions(+), 42 deletions(-)
|
||||
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index 5c8c7764..c2b0a1a5 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -243,9 +243,6 @@ AC_ARG_WITH(skey,
|
||||
AC_ARG_WITH(tcb,
|
||||
[AS_HELP_STRING([--with-tcb], [use tcb support (incomplete) @<:@default=yes if found@:>@])],
|
||||
[with_tcb=$withval], [with_tcb=maybe])
|
||||
-AC_ARG_WITH(libcrack,
|
||||
- [AS_HELP_STRING([--with-libcrack], [use libcrack @<:@default=no@:>@])],
|
||||
- [with_libcrack=$withval], [with_libcrack=no])
|
||||
AC_ARG_WITH(sha-crypt,
|
||||
[AS_HELP_STRING([--with-sha-crypt], [allow the SHA256 and SHA512 password encryption algorithms @<:@default=yes@:>@])],
|
||||
[with_sha_crypt=$withval], [with_sha_crypt=yes])
|
||||
@@ -521,13 +518,6 @@ if test "$with_audit" != "no"; then
|
||||
fi
|
||||
fi
|
||||
|
||||
-AC_SUBST(LIBCRACK)
|
||||
-if test "$with_libcrack" = "yes"; then
|
||||
- echo "checking cracklib flavour, don't be surprised by the results"
|
||||
- AC_CHECK_LIB(crack, FascistCheck,
|
||||
- [LIBCRACK=-lcrack AC_DEFINE(HAVE_LIBCRACK, 1, [Defined if you have libcrack.])])
|
||||
-fi
|
||||
-
|
||||
if test "$with_btrfs" != "no"; then
|
||||
AC_CHECK_HEADERS([sys/statfs.h linux/magic.h linux/btrfs_tree.h], \
|
||||
[btrfs_headers="yes"], [btrfs_headers="no"])
|
||||
@@ -768,7 +758,6 @@ echo
|
||||
echo "shadow will be compiled with the following features:"
|
||||
echo
|
||||
echo " auditing support: $with_audit"
|
||||
-echo " CrackLib support: $with_libcrack"
|
||||
echo " PAM support: $with_libpam"
|
||||
if test "$with_libpam" = "yes"; then
|
||||
echo " suid account management tools: $enable_acct_tools_setuid"
|
||||
diff --git a/etc/login.defs b/etc/login.defs
|
||||
index 114dbcd9..33622c29 100644
|
||||
--- a/etc/login.defs
|
||||
+++ b/etc/login.defs
|
||||
@@ -227,11 +227,6 @@ PASS_WARN_AGE 7
|
||||
#
|
||||
SU_WHEEL_ONLY no
|
||||
|
||||
-#
|
||||
-# If compiled with cracklib support, sets the path to the dictionaries
|
||||
-#
|
||||
-CRACKLIB_DICTPATH /var/cache/cracklib/cracklib_dict
|
||||
-
|
||||
#
|
||||
# Min/max values for automatic uid selection in useradd(8)
|
||||
#
|
||||
diff --git a/lib/getdef.c b/lib/getdef.c
|
||||
index 977660c2..d64e6343 100644
|
||||
--- a/lib/getdef.c
|
||||
+++ b/lib/getdef.c
|
||||
@@ -39,7 +39,6 @@ struct itemdef {
|
||||
#define PAMDEFS \
|
||||
{"CHFN_AUTH", NULL}, \
|
||||
{"CHSH_AUTH", NULL}, \
|
||||
- {"CRACKLIB_DICTPATH", NULL}, \
|
||||
{"ENV_HZ", NULL}, \
|
||||
{"ENVIRON_FILE", NULL}, \
|
||||
{"ENV_TZ", NULL}, \
|
||||
diff --git a/libmisc/obscure.c b/libmisc/obscure.c
|
||||
index 4070d4e4..2aece68b 100644
|
||||
--- a/libmisc/obscure.c
|
||||
+++ b/libmisc/obscure.c
|
||||
@@ -12,11 +12,6 @@
|
||||
#ident "$Id$"
|
||||
|
||||
|
||||
-/*
|
||||
- * This version of obscure.c contains modifications to support "cracklib"
|
||||
- * by Alec Muffet (alec.muffett@uk.sun.com). You must obtain the Cracklib
|
||||
- * library source code for this function to operate.
|
||||
- */
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -97,12 +92,6 @@ static /*@observer@*//*@null@*/const char *password_check (
|
||||
const char *msg = NULL;
|
||||
char *oldmono, *newmono, *wrapped;
|
||||
|
||||
-#ifdef HAVE_LIBCRACK
|
||||
- char *dictpath;
|
||||
-
|
||||
- char *FascistCheck ();
|
||||
-#endif
|
||||
-
|
||||
if (strcmp (new, old) == 0) {
|
||||
return _("no change");
|
||||
}
|
||||
@@ -121,17 +110,6 @@ static /*@observer@*//*@null@*/const char *password_check (
|
||||
msg = _("too similar");
|
||||
} else if (strstr (wrapped, newmono) != NULL) {
|
||||
msg = _("rotated");
|
||||
- } else {
|
||||
-#ifdef HAVE_LIBCRACK
|
||||
- /*
|
||||
- * Invoke Alec Muffett's cracklib routines.
|
||||
- */
|
||||
-
|
||||
- dictpath = getdef_str ("CRACKLIB_DICTPATH");
|
||||
- if (NULL != dictpath) {
|
||||
- msg = FascistCheck (new, dictpath);
|
||||
- }
|
||||
-#endif
|
||||
}
|
||||
strzero (newmono);
|
||||
strzero (oldmono);
|
||||
diff --git a/libsubid/Makefile.am b/libsubid/Makefile.am
|
||||
index 5ba0ab35..b6488e77 100644
|
||||
--- a/libsubid/Makefile.am
|
||||
+++ b/libsubid/Makefile.am
|
||||
@@ -8,7 +8,6 @@ MISCLIBS = \
|
||||
$(LIBAUDIT) \
|
||||
$(LIBSELINUX) \
|
||||
$(LIBSEMANAGE) \
|
||||
- $(LIBCRACK) \
|
||||
$(LIBCRYPT_NOPAM) \
|
||||
$(LIBSKEY) \
|
||||
$(LIBMD) \
|
||||
diff --git a/src/Makefile.am b/src/Makefile.am
|
||||
index fcfee9d2..b6cb09ef 100644
|
||||
--- a/src/Makefile.am
|
||||
+++ b/src/Makefile.am
|
||||
@@ -123,7 +123,7 @@ login_LDADD = $(LDADD) $(LIBPAM) $(LIBAUDIT) $(LIBCRYPT_NOPAM) $(LIBSKEY) $(L
|
||||
newgrp_LDADD = $(LDADD) $(LIBAUDIT) $(LIBCRYPT) $(LIBECONF)
|
||||
newusers_LDADD = $(LDADD) $(LIBPAM) $(LIBAUDIT) $(LIBSELINUX) $(LIBCRYPT) $(LIBECONF) -ldl
|
||||
nologin_LDADD =
|
||||
-passwd_LDADD = $(LDADD) $(LIBPAM) $(LIBCRACK) $(LIBAUDIT) $(LIBSELINUX) $(LIBCRYPT_NOPAM) $(LIBECONF) -ldl
|
||||
+passwd_LDADD = $(LDADD) $(LIBPAM) $(LIBAUDIT) $(LIBSELINUX) $(LIBCRYPT_NOPAM) $(LIBECONF) -ldl
|
||||
pwck_LDADD = $(LDADD) $(LIBAUDIT) $(LIBSELINUX) $(LIBECONF)
|
||||
pwconv_LDADD = $(LDADD) $(LIBAUDIT) $(LIBSELINUX) $(LIBECONF)
|
||||
pwunconv_LDADD = $(LDADD) $(LIBAUDIT) $(LIBSELINUX) $(LIBECONF)
|
||||
--
|
||||
2.43.0
|
||||
|
||||
|
|
@ -1,380 +0,0 @@
|
|||
diff -up shadow-4.15.0/src/chpasswd.c.account-tools-setuid shadow-4.15.0/src/chpasswd.c
|
||||
--- shadow-4.15.0/src/chpasswd.c.account-tools-setuid 2024-03-08 22:27:04.000000000 +0100
|
||||
+++ shadow-4.15.0/src/chpasswd.c 2024-03-11 11:21:57.561150382 +0100
|
||||
@@ -443,9 +443,11 @@ int main (int argc, char **argv)
|
||||
char *cp;
|
||||
const char *salt;
|
||||
|
||||
+#ifdef ACCT_TOOLS_SETUID
|
||||
#ifdef USE_PAM
|
||||
bool use_pam = true;
|
||||
#endif /* USE_PAM */
|
||||
+#endif /* ACCT_TOOLS_SETUID */
|
||||
|
||||
int errors = 0;
|
||||
int line = 0;
|
||||
@@ -469,19 +471,23 @@ int main (int argc, char **argv)
|
||||
process_root_flag ("-R", argc, argv);
|
||||
prefix = process_prefix_flag ("-P", argc, argv);
|
||||
|
||||
+#ifdef ACCT_TOOLS_SETUID
|
||||
#ifdef USE_PAM
|
||||
if (md5flg || eflg || cflg || prefix[0]) {
|
||||
use_pam = false;
|
||||
}
|
||||
#endif /* USE_PAM */
|
||||
+#endif /* ACCT_TOOLS_SETUID */
|
||||
|
||||
OPENLOG (Prog);
|
||||
|
||||
check_perms ();
|
||||
|
||||
+#ifdef ACCT_TOOLS_SETUID
|
||||
#ifdef USE_PAM
|
||||
if (!use_pam)
|
||||
#endif /* USE_PAM */
|
||||
+#endif /* ACCT_TOOLS_SETUID */
|
||||
{
|
||||
is_shadow_pwd = spw_file_present ();
|
||||
|
||||
@@ -543,6 +549,7 @@ int main (int argc, char **argv)
|
||||
}
|
||||
newpwd = cp;
|
||||
|
||||
+#ifdef ACCT_TOOLS_SETUID
|
||||
#ifdef USE_PAM
|
||||
if (use_pam) {
|
||||
if (do_pam_passwd_non_interactive (Prog, name, newpwd) != 0) {
|
||||
@@ -553,6 +560,7 @@ int main (int argc, char **argv)
|
||||
}
|
||||
} else
|
||||
#endif /* USE_PAM */
|
||||
+#endif /* ACCT_TOOLS_SETUID */
|
||||
{
|
||||
const struct spwd *sp;
|
||||
struct spwd newsp;
|
||||
@@ -672,9 +680,11 @@ int main (int argc, char **argv)
|
||||
* password database.
|
||||
*/
|
||||
if (0 != errors) {
|
||||
+#ifdef ACCT_TOOLS_SETUID
|
||||
#ifdef USE_PAM
|
||||
if (!use_pam)
|
||||
#endif /* USE_PAM */
|
||||
+#endif /* ACCT_TOOLS_SETUID */
|
||||
{
|
||||
fprintf (stderr,
|
||||
_("%s: error detected, changes ignored\n"),
|
||||
@@ -683,9 +693,11 @@ int main (int argc, char **argv)
|
||||
fail_exit (1);
|
||||
}
|
||||
|
||||
+#ifdef ACCT_TOOLS_SETUID
|
||||
#ifdef USE_PAM
|
||||
if (!use_pam)
|
||||
#endif /* USE_PAM */
|
||||
+#endif /* ACCT_TOOLS_SETUID */
|
||||
{
|
||||
/* Save the changes */
|
||||
close_files ();
|
||||
diff -up shadow-4.15.0/src/groupmems.c.account-tools-setuid shadow-4.15.0/src/groupmems.c
|
||||
--- shadow-4.15.0/src/groupmems.c.account-tools-setuid 2024-03-08 22:27:04.000000000 +0100
|
||||
+++ shadow-4.15.0/src/groupmems.c 2024-03-11 11:16:18.365408572 +0100
|
||||
@@ -14,9 +14,11 @@
|
||||
#include <grp.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
+#ifdef ACCT_TOOLS_SETUID
|
||||
#ifdef USE_PAM
|
||||
#include "pam_defs.h"
|
||||
#endif /* USE_PAM */
|
||||
+#endif /* ACCT_TOOLS_SETUID */
|
||||
#include <pwd.h>
|
||||
|
||||
#include "alloc.h"
|
||||
@@ -430,6 +432,7 @@ static void process_flags (int argc, cha
|
||||
static void check_perms (void)
|
||||
{
|
||||
if (!list) {
|
||||
+#ifdef ACCT_TOOLS_SETUID
|
||||
#ifdef USE_PAM
|
||||
pam_handle_t *pamh = NULL;
|
||||
int retval;
|
||||
@@ -463,7 +466,8 @@ static void check_perms (void)
|
||||
fail_exit (1);
|
||||
}
|
||||
(void) pam_end (pamh, retval);
|
||||
-#endif
|
||||
+#endif /* USE_PAM */
|
||||
+#endif /* ACCT_TOOLS_SETUID */
|
||||
}
|
||||
}
|
||||
|
||||
diff -up shadow-4.15.0/src/newusers.c.account-tools-setuid shadow-4.15.0/src/newusers.c
|
||||
--- shadow-4.15.0/src/newusers.c.account-tools-setuid 2024-03-08 22:27:04.000000000 +0100
|
||||
+++ shadow-4.15.0/src/newusers.c 2024-03-11 11:20:07.198909046 +0100
|
||||
@@ -59,6 +59,7 @@
|
||||
static const char Prog[] = "newusers";
|
||||
|
||||
static bool rflg = false; /* create a system account */
|
||||
+#ifndef ACCT_TOOLS_SETUID
|
||||
#ifndef USE_PAM
|
||||
static /*@null@*//*@observer@*/char *crypt_method = NULL;
|
||||
#define cflg (NULL != crypt_method)
|
||||
@@ -75,6 +76,7 @@ static long bcrypt_rounds = 13;
|
||||
static long yescrypt_cost = 5;
|
||||
#endif /* USE_YESCRYPT */
|
||||
#endif /* !USE_PAM */
|
||||
+#endif /* !ACCT_TOOLS_SETUID */
|
||||
|
||||
static bool is_shadow;
|
||||
#ifdef SHADOWGRP
|
||||
@@ -97,9 +99,11 @@ NORETURN static void fail_exit (int);
|
||||
static int add_group (const char *, const char *, gid_t *, gid_t);
|
||||
static int get_user_id (const char *, uid_t *);
|
||||
static int add_user (const char *, uid_t, gid_t);
|
||||
+#ifndef ACCT_TOOLS_SETUID
|
||||
#ifndef USE_PAM
|
||||
static int update_passwd (struct passwd *, const char *);
|
||||
#endif /* !USE_PAM */
|
||||
+#endif /* !ACCT_TOOLS_SETUID */
|
||||
static int add_passwd (struct passwd *, const char *);
|
||||
static void process_flags (int argc, char **argv);
|
||||
static void check_flags (void);
|
||||
@@ -121,6 +125,7 @@ static void usage (int status)
|
||||
"Options:\n"),
|
||||
Prog);
|
||||
(void) fputs (_(" -b, --badname allow bad names\n"), usageout);
|
||||
+#ifndef ACCT_TOOLS_SETUID
|
||||
#ifndef USE_PAM
|
||||
(void) fprintf (usageout,
|
||||
_(" -c, --crypt-method METHOD the crypt method (one of %s)\n"),
|
||||
@@ -136,9 +141,11 @@ static void usage (int status)
|
||||
#endif
|
||||
);
|
||||
#endif /* !USE_PAM */
|
||||
+#endif /* !ACCT_TOOLS_SETUID */
|
||||
(void) fputs (_(" -h, --help display this help message and exit\n"), usageout);
|
||||
(void) fputs (_(" -r, --system create system accounts\n"), usageout);
|
||||
(void) fputs (_(" -R, --root CHROOT_DIR directory to chroot into\n"), usageout);
|
||||
+#ifndef ACCT_TOOLS_SETUID
|
||||
#ifndef USE_PAM
|
||||
#if defined(USE_SHA_CRYPT) || defined(USE_BCRYPT) || defined(USE_YESCRYPT)
|
||||
(void) fputs (_(" -s, --sha-rounds number of rounds for the SHA, BCRYPT\n"
|
||||
@@ -146,6 +153,7 @@ static void usage (int status)
|
||||
usageout);
|
||||
#endif /* USE_SHA_CRYPT || USE_BCRYPT || USE_YESCRYPT */
|
||||
#endif /* !USE_PAM */
|
||||
+#endif /* !ACCT_TOOLS_SETUID */
|
||||
(void) fputs ("\n", usageout);
|
||||
|
||||
exit (status);
|
||||
@@ -405,6 +413,7 @@ static int add_user (const char *name, u
|
||||
return (pw_update (&pwent) == 0) ? -1 : 0;
|
||||
}
|
||||
|
||||
+#ifndef ACCT_TOOLS_SETUID
|
||||
#ifndef USE_PAM
|
||||
/*
|
||||
* update_passwd - update the password in the passwd entry
|
||||
@@ -457,6 +466,7 @@ static int update_passwd (struct passwd
|
||||
return 0;
|
||||
}
|
||||
#endif /* !USE_PAM */
|
||||
+#endif /* !ACCT_TOOLS_SETUID */
|
||||
|
||||
/*
|
||||
* add_passwd - add or update the encrypted password
|
||||
@@ -465,10 +475,13 @@ static int add_passwd (struct passwd *pw
|
||||
{
|
||||
const struct spwd *sp;
|
||||
struct spwd spent;
|
||||
+#ifndef ACCT_TOOLS_SETUID
|
||||
#ifndef USE_PAM
|
||||
char *cp;
|
||||
#endif /* !USE_PAM */
|
||||
+#endif /* !ACCT_TOOLS_SETUID */
|
||||
|
||||
+#ifndef ACCT_TOOLS_SETUID
|
||||
#ifndef USE_PAM
|
||||
void *crypt_arg = NULL;
|
||||
if (NULL != crypt_method) {
|
||||
@@ -505,13 +518,14 @@ static int add_passwd (struct passwd *pw
|
||||
return update_passwd (pwd, password);
|
||||
}
|
||||
#endif /* USE_PAM */
|
||||
+#endif /* !ACCT_TOOLS_SETUID */
|
||||
|
||||
/*
|
||||
* Do the first and easiest shadow file case. The user already
|
||||
* exists in the shadow password file.
|
||||
*/
|
||||
sp = spw_locate (pwd->pw_name);
|
||||
-#ifndef USE_PAM
|
||||
+#if !defined(ACCT_TOOLS_SETUID) && !defined(USE_PAM)
|
||||
if (NULL != sp) {
|
||||
spent = *sp;
|
||||
if ( (NULL != crypt_method)
|
||||
@@ -547,7 +561,7 @@ static int add_passwd (struct passwd *pw
|
||||
if (strcmp (pwd->pw_passwd, "x") != 0) {
|
||||
return update_passwd (pwd, password);
|
||||
}
|
||||
-#else /* USE_PAM */
|
||||
+#else /* !ACCT_TOOLS_SETUID && !USE_PAM */
|
||||
/*
|
||||
* If there is already a shadow entry, do not touch it.
|
||||
* If there is already a passwd entry with a password, do not
|
||||
@@ -558,14 +572,14 @@ static int add_passwd (struct passwd *pw
|
||||
|| (strcmp (pwd->pw_passwd, "x") != 0)) {
|
||||
return 0;
|
||||
}
|
||||
-#endif /* USE_PAM */
|
||||
+#endif /* !ACCT_TOOLS_SETUID && !USE_PAM */
|
||||
|
||||
/*
|
||||
* Now the really hard case - I need to create an entirely new
|
||||
* shadow password file entry.
|
||||
*/
|
||||
spent.sp_namp = pwd->pw_name;
|
||||
-#ifndef USE_PAM
|
||||
+#if !defined(ACCT_TOOLS_SETUID) && !defined(USE_PAM)
|
||||
if ((crypt_method != NULL) && (0 == strcmp(crypt_method, "NONE"))) {
|
||||
spent.sp_pwdp = (char *)password;
|
||||
} else {
|
||||
@@ -610,35 +624,41 @@ static int add_passwd (struct passwd *pw
|
||||
static void process_flags (int argc, char **argv)
|
||||
{
|
||||
int c;
|
||||
+#ifndef ACCT_TOOLS_SETUID
|
||||
#ifndef USE_PAM
|
||||
#if defined(USE_SHA_CRYPT) || defined(USE_BCRYPT) || defined(USE_YESCRYPT)
|
||||
int bad_s;
|
||||
#endif /* USE_SHA_CRYPT || USE_BCRYPT || USE_YESCRYPT */
|
||||
#endif /* !USE_PAM */
|
||||
+#endif /* !ACCT_TOOLS_SETUID */
|
||||
static struct option long_options[] = {
|
||||
{"badname", no_argument, NULL, 'b'},
|
||||
+#ifndef ACCT_TOOLS_SETUID
|
||||
#ifndef USE_PAM
|
||||
{"crypt-method", required_argument, NULL, 'c'},
|
||||
#endif /* !USE_PAM */
|
||||
+#endif /* !ACCT_TOOLS_SETUID */
|
||||
{"help", no_argument, NULL, 'h'},
|
||||
{"system", no_argument, NULL, 'r'},
|
||||
{"root", required_argument, NULL, 'R'},
|
||||
+#ifndef ACCT_TOOLS_SETUID
|
||||
#ifndef USE_PAM
|
||||
#if defined(USE_SHA_CRYPT) || defined(USE_BCRYPT) || defined(USE_YESCRYPT)
|
||||
{"sha-rounds", required_argument, NULL, 's'},
|
||||
#endif /* USE_SHA_CRYPT || USE_BCRYPT || USE_YESCRYPT */
|
||||
#endif /* !USE_PAM */
|
||||
+#endif /* !ACCT_TOOLS_SETUID */
|
||||
{NULL, 0, NULL, '\0'}
|
||||
};
|
||||
|
||||
while ((c = getopt_long (argc, argv,
|
||||
-#ifndef USE_PAM
|
||||
+#if !defined(ACCT_TOOLS_SETUID) && !defined(USE_PAM)
|
||||
#if defined(USE_SHA_CRYPT) || defined(USE_BCRYPT) || defined(USE_YESCRYPT)
|
||||
"c:bhrs:",
|
||||
#else /* !USE_SHA_CRYPT && !USE_BCRYPT && !USE_YESCRYPT */
|
||||
"c:bhr",
|
||||
#endif /* USE_SHA_CRYPT || USE_BCRYPT || USE_YESCRYPT */
|
||||
-#else /* USE_PAM */
|
||||
+#else /* !ACCT_TOOLS_SETUID && !USE_PAM */
|
||||
"bhr",
|
||||
#endif
|
||||
long_options, NULL)) != -1) {
|
||||
@@ -646,11 +666,13 @@ static void process_flags (int argc, cha
|
||||
case 'b':
|
||||
allow_bad_names = true;
|
||||
break;
|
||||
+#ifndef ACCT_TOOLS_SETUID
|
||||
#ifndef USE_PAM
|
||||
case 'c':
|
||||
crypt_method = optarg;
|
||||
break;
|
||||
#endif /* !USE_PAM */
|
||||
+#endif /* !ACCT_TOOLS_SETUID */
|
||||
case 'h':
|
||||
usage (EXIT_SUCCESS);
|
||||
break;
|
||||
@@ -659,6 +681,7 @@ static void process_flags (int argc, cha
|
||||
break;
|
||||
case 'R': /* no-op, handled in process_root_flag () */
|
||||
break;
|
||||
+#ifndef ACCT_TOOLS_SETUID
|
||||
#ifndef USE_PAM
|
||||
#if defined(USE_SHA_CRYPT) || defined(USE_BCRYPT) || defined(USE_YESCRYPT)
|
||||
case 's':
|
||||
@@ -698,6 +721,7 @@ static void process_flags (int argc, cha
|
||||
break;
|
||||
#endif /* USE_SHA_CRYPT || USE_BCRYPT || USE_YESCRYPT */
|
||||
#endif /* !USE_PAM */
|
||||
+#endif /* !ACCT_TOOLS_SETUID */
|
||||
default:
|
||||
usage (EXIT_FAILURE);
|
||||
break;
|
||||
@@ -730,6 +754,7 @@ static void process_flags (int argc, cha
|
||||
*/
|
||||
static void check_flags (void)
|
||||
{
|
||||
+#ifndef ACCT_TOOLS_SETUID
|
||||
#ifndef USE_PAM
|
||||
#if defined(USE_SHA_CRYPT) || defined(USE_BCRYPT) || defined(USE_YESCRYPT)
|
||||
if (sflg && !cflg) {
|
||||
@@ -762,6 +787,7 @@ static void check_flags (void)
|
||||
}
|
||||
}
|
||||
#endif /* !USE_PAM */
|
||||
+#endif /* !ACCT_TOOLS_SETUID */
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1052,12 +1078,14 @@ int main (int argc, char **argv)
|
||||
int line = 0;
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
+#ifdef ACCT_TOOLS_SETUID
|
||||
#ifdef USE_PAM
|
||||
int *lines = NULL;
|
||||
char **usernames = NULL;
|
||||
char **passwords = NULL;
|
||||
unsigned int nusers = 0;
|
||||
#endif /* USE_PAM */
|
||||
+#endif /* ACCT_TOOLS_SETUID */
|
||||
|
||||
log_set_progname(Prog);
|
||||
log_set_logfd(stderr);
|
||||
@@ -1195,6 +1223,7 @@ int main (int argc, char **argv)
|
||||
}
|
||||
newpw = *pw;
|
||||
|
||||
+#ifdef ACCT_TOOLS_SETUID
|
||||
#ifdef USE_PAM
|
||||
/* keep the list of user/password for later update by PAM */
|
||||
nusers++;
|
||||
@@ -1211,6 +1240,7 @@ int main (int argc, char **argv)
|
||||
usernames[nusers-1] = strdup (fields[0]);
|
||||
passwords[nusers-1] = strdup (fields[1]);
|
||||
#endif /* USE_PAM */
|
||||
+#endif /* ACCT_TOOLS_SETUID */
|
||||
if (add_passwd (&newpw, fields[1]) != 0) {
|
||||
fprintf (stderr,
|
||||
_("%s: line %d: can't update password\n"),
|
||||
@@ -1327,6 +1357,7 @@ int main (int argc, char **argv)
|
||||
nscd_flush_cache ("group");
|
||||
sssd_flush_cache (SSSD_DB_PASSWD | SSSD_DB_GROUP);
|
||||
|
||||
+#ifdef ACCT_TOOLS_SETUID
|
||||
#ifdef USE_PAM
|
||||
unsigned int i;
|
||||
/* Now update the passwords using PAM */
|
||||
@@ -1339,6 +1370,7 @@ int main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
#endif /* USE_PAM */
|
||||
+#endif /* ACCT_TOOLS_SETUID */
|
||||
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
|
@ -1,137 +0,0 @@
|
|||
From ead55e9ba8958504e23e29545f90c4dd925c7462 Mon Sep 17 00:00:00 2001
|
||||
From: Serge Hallyn <serge@hallyn.com>
|
||||
Date: Wed, 20 Mar 2024 17:39:46 -0500
|
||||
Subject: [PATCH] getdef: avoid spurious error messages about unknown
|
||||
configuration options
|
||||
|
||||
def_find can return NULL for unset, not just unknown, config options. So
|
||||
move the decision of whether to log an error message about an unknown config
|
||||
option back into def_find, which knows the difference. Only putdef_str()
|
||||
will pass a char* srcfile to def_find, so only calls from putdef_str will
|
||||
cause the message, which was the original intent of fa68441bc4be8.
|
||||
|
||||
closes #967
|
||||
|
||||
fixes: fa68441bc4be8 ("Improve the login.defs unknown item error message")
|
||||
Signed-off-by: Serge Hallyn <serge@hallyn.com>
|
||||
---
|
||||
lib/getdef.c | 30 ++++++++++++++++--------------
|
||||
1 file changed, 16 insertions(+), 14 deletions(-)
|
||||
|
||||
diff --git a/lib/getdef.c b/lib/getdef.c
|
||||
index 4d4d4e19..ef2ae1f0 100644
|
||||
--- a/lib/getdef.c
|
||||
+++ b/lib/getdef.c
|
||||
@@ -176,7 +176,7 @@ static const char* def_fname = LOGINDEFS; /* login config defs file */
|
||||
static bool def_loaded = false; /* are defs already loaded? */
|
||||
|
||||
/* local function prototypes */
|
||||
-static /*@observer@*/ /*@null@*/struct itemdef *def_find (const char *);
|
||||
+static /*@observer@*/ /*@null@*/struct itemdef *def_find (const char *, const char *);
|
||||
static void def_load (void);
|
||||
|
||||
|
||||
@@ -195,7 +195,7 @@ static void def_load (void);
|
||||
def_load ();
|
||||
}
|
||||
|
||||
- d = def_find (item);
|
||||
+ d = def_find (item, NULL);
|
||||
return (NULL == d) ? NULL : d->value;
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ bool getdef_bool (const char *item)
|
||||
def_load ();
|
||||
}
|
||||
|
||||
- d = def_find (item);
|
||||
+ d = def_find (item, NULL);
|
||||
if ((NULL == d) || (NULL == d->value)) {
|
||||
return false;
|
||||
}
|
||||
@@ -240,7 +240,7 @@ int getdef_num (const char *item, int dflt)
|
||||
def_load ();
|
||||
}
|
||||
|
||||
- d = def_find (item);
|
||||
+ d = def_find (item, NULL);
|
||||
if ((NULL == d) || (NULL == d->value)) {
|
||||
return dflt;
|
||||
}
|
||||
@@ -275,7 +275,7 @@ unsigned int getdef_unum (const char *item, unsigned int dflt)
|
||||
def_load ();
|
||||
}
|
||||
|
||||
- d = def_find (item);
|
||||
+ d = def_find (item, NULL);
|
||||
if ((NULL == d) || (NULL == d->value)) {
|
||||
return dflt;
|
||||
}
|
||||
@@ -310,7 +310,7 @@ long getdef_long (const char *item, long dflt)
|
||||
def_load ();
|
||||
}
|
||||
|
||||
- d = def_find (item);
|
||||
+ d = def_find (item, NULL);
|
||||
if ((NULL == d) || (NULL == d->value)) {
|
||||
return dflt;
|
||||
}
|
||||
@@ -342,7 +342,7 @@ unsigned long getdef_ulong (const char *item, unsigned long dflt)
|
||||
def_load ();
|
||||
}
|
||||
|
||||
- d = def_find (item);
|
||||
+ d = def_find (item, NULL);
|
||||
if ((NULL == d) || (NULL == d->value)) {
|
||||
return dflt;
|
||||
}
|
||||
@@ -375,12 +375,9 @@ int putdef_str (const char *name, const char *value, const char *srcfile)
|
||||
* Locate the slot to save the value. If this parameter
|
||||
* is unknown then "def_find" will print an err message.
|
||||
*/
|
||||
- d = def_find (name);
|
||||
- if (NULL == d) {
|
||||
- if (NULL != srcfile)
|
||||
- SYSLOG ((LOG_CRIT, "shadow: unknown configuration item '%s' in '%s'", name, srcfile));
|
||||
+ d = def_find (name, srcfile);
|
||||
+ if (NULL == d)
|
||||
return -1;
|
||||
- }
|
||||
|
||||
/*
|
||||
* Save off the value.
|
||||
@@ -404,9 +401,12 @@ int putdef_str (const char *name, const char *value, const char *srcfile)
|
||||
*
|
||||
* Search through a table of configurable items to locate the
|
||||
* specified configuration option.
|
||||
+ *
|
||||
+ * If srcfile is not NULL, and the item is not found, then report an error saying
|
||||
+ * the unknown item was used in this file.
|
||||
*/
|
||||
|
||||
-static /*@observer@*/ /*@null@*/struct itemdef *def_find (const char *name)
|
||||
+static /*@observer@*/ /*@null@*/struct itemdef *def_find (const char *name, const char *srcfile)
|
||||
{
|
||||
struct itemdef *ptr;
|
||||
|
||||
@@ -432,6 +432,8 @@ static /*@observer@*/ /*@null@*/struct itemdef *def_find (const char *name)
|
||||
fprintf (shadow_logfd,
|
||||
_("configuration error - unknown item '%s' (notify administrator)\n"),
|
||||
name);
|
||||
+ if (srcfile != NULL)
|
||||
+ SYSLOG ((LOG_CRIT, "shadow: unknown configuration item '%s' in '%s'", name, srcfile));
|
||||
|
||||
out:
|
||||
return NULL;
|
||||
@@ -610,7 +612,7 @@ int main (int argc, char **argv)
|
||||
def_load ();
|
||||
|
||||
for (i = 0; i < NUMDEFS; ++i) {
|
||||
- d = def_find (def_table[i].name);
|
||||
+ d = def_find (def_table[i].name, NULL);
|
||||
if (NULL == d) {
|
||||
printf ("error - lookup '%s' failed\n",
|
||||
def_table[i].name);
|
||||
--
|
||||
2.44.0
|
||||
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
From c1678a9e2759f60a2daf5e136c76fa6e47d6f400 Mon Sep 17 00:00:00 2001
|
||||
From: Alejandro Colomar <alx@kernel.org>
|
||||
Date: Wed, 30 Jul 2025 00:18:33 +0200
|
||||
Subject: [PATCH] src/groupmod.c: --help: wfix
|
||||
|
||||
Closes: <https://github.com/shadow-maint/shadow/issues/1313>
|
||||
Reported-by: Arshdeep Singh <arshdeepsinghsahni8@gmail.com>
|
||||
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
||||
---
|
||||
src/groupmod.c | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/groupmod.c b/src/groupmod.c
|
||||
index 34b670f6..2cdb2067 100644
|
||||
--- a/src/groupmod.c
|
||||
+++ b/src/groupmod.c
|
||||
@@ -132,7 +132,8 @@ static void usage (int status)
|
||||
" PASSWORD\n"), usageout);
|
||||
(void) fputs (_(" -R, --root CHROOT_DIR directory to chroot into\n"), usageout);
|
||||
(void) fputs (_(" -P, --prefix PREFIX_DIR prefix directory where are located the /etc/* files\n"), usageout);
|
||||
- (void) fputs (_(" -U, --users USERS list of user members of this group\n"), usageout);
|
||||
+ (void) fputs (_(" -U, --users USERS comma-separated list of users to add as\n"
|
||||
+ " members of this group\n"), usageout);
|
||||
(void) fputs ("\n", usageout);
|
||||
exit (status);
|
||||
}
|
||||
--
|
||||
2.52.0
|
||||
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
From 10429edc14673fbb8c78b25f1872c34e88e5f07f Mon Sep 17 00:00:00 2001
|
||||
From: lixinyun <li.xinyun@h3c.com>
|
||||
Date: Wed, 29 May 2024 06:53:02 +0800
|
||||
Subject: [PATCH] src/groupmod.c: delete gr_free_members(&grp) to avoid double
|
||||
free
|
||||
|
||||
Groupmod -U may cause crashes because of double free. If without -a, the first free of (*ogrp).gr_mem is in gr_free_members(&grp), and then in gr_update without -n or gr_remove with -n.
|
||||
Considering the minimal impact of modifications on existing code, delete gr_free_members(&grp) to avoid double free.Although this may seem reckless, the second free in two different positions will definitely be triggered, and the following two test cases can be used to illustrate the situation :
|
||||
|
||||
[root@localhost src]# ./useradd u1
|
||||
[root@localhost src]# ./useradd u2
|
||||
[root@localhost src]# ./useradd u3
|
||||
[root@localhost src]# ./groupadd -U u1,u2,u3 g1
|
||||
[root@localhost src]# ./groupmod -n g2 -U u1,u2 g1
|
||||
Segmentation fault
|
||||
|
||||
This case would free (*ogrp).gr_mem in gr_free_members(&grp) due to assignment statements grp = *ogrp, then in if (nflg && (gr_remove (group_name) == 0)), which finally calls gr_free_members(grent) to free (*ogrp).gr_mem again.
|
||||
|
||||
[root@localhost src]# ./useradd u1
|
||||
[root@localhost src]# ./useradd u2
|
||||
[root@localhost src]# ./useradd u3
|
||||
[root@localhost src]# ./groupadd -U u1,u2,u3 g1
|
||||
[root@localhost src]# ./groupmod -U u1,u2 g1
|
||||
Segmentation fault
|
||||
|
||||
The other case would free (*ogrp).gr_mem in gr_free_members(&grp) too, then in if (gr_update (&grp) == 0), which finally calls gr_free_members(grent) too to free (*ogrp).gr_mem again.
|
||||
|
||||
So the first free is unnecessary, maybe we can drop it.
|
||||
|
||||
Fixes: 342c934a3590 ("add -U option to groupadd and groupmod")
|
||||
Closes: <https://github.com/shadow-maint/shadow/issues/1013>
|
||||
Link: <https://github.com/shadow-maint/shadow/pull/1007>
|
||||
Link: <https://github.com/shadow-maint/shadow/pull/271>
|
||||
Link: <https://github.com/shadow-maint/shadow/issues/265>
|
||||
Cc: "Serge E. Hallyn" <serge@hallyn.com>
|
||||
Reviewed-by: Alejandro Colomar <alx@kernel.org>
|
||||
Signed-off-by: lixinyun <li.xinyun@h3c.com>
|
||||
---
|
||||
src/groupmod.c | 2 --
|
||||
1 file changed, 2 deletions(-)
|
||||
|
||||
diff --git a/src/groupmod.c b/src/groupmod.c
|
||||
index a29cf73f..989d7ea3 100644
|
||||
--- a/src/groupmod.c
|
||||
+++ b/src/groupmod.c
|
||||
@@ -250,8 +250,6 @@ static void grp_update (void)
|
||||
|
||||
if (!aflg) {
|
||||
// requested to replace the existing groups
|
||||
- if (NULL != grp.gr_mem[0])
|
||||
- gr_free_members(&grp);
|
||||
grp.gr_mem = XMALLOC(1, char *);
|
||||
grp.gr_mem[0] = NULL;
|
||||
} else {
|
||||
--
|
||||
2.54.0
|
||||
|
||||
|
|
@ -1,176 +0,0 @@
|
|||
From 7b3deac2de133c45af5b266c573e7ec0b9157b0b Mon Sep 17 00:00:00 2001
|
||||
From: Iker Pedrosa <ipedrosa@redhat.com>
|
||||
Date: Mon, 9 Feb 2026 10:03:32 +0100
|
||||
Subject: [PATCH] src/passwd.c: add audit messages for passwd
|
||||
|
||||
Add comprehensive audit messages for password operations, including
|
||||
unlock, delete, expire and aging operations.
|
||||
|
||||
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
|
||||
---
|
||||
src/passwd.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++++---
|
||||
1 file changed, 95 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/passwd.c b/src/passwd.c
|
||||
index 0afae4d7..1fa99448 100644
|
||||
--- a/src/passwd.c
|
||||
+++ b/src/passwd.c
|
||||
@@ -547,6 +547,7 @@ static void update_noshadow (void)
|
||||
{
|
||||
const struct passwd *pw;
|
||||
struct passwd *npw;
|
||||
+ int ret;
|
||||
|
||||
if (pw_lock () == 0) {
|
||||
(void) fprintf (stderr,
|
||||
@@ -573,8 +574,29 @@ static void update_noshadow (void)
|
||||
if (NULL == npw) {
|
||||
oom ();
|
||||
}
|
||||
- npw->pw_passwd = update_crypt_pw (npw->pw_passwd);
|
||||
- if (pw_update (npw) == 0) {
|
||||
+ npw->pw_passwd = update_crypt_pw (npw->pw_passwd);
|
||||
+ ret = pw_update(npw);
|
||||
+#ifdef WITH_AUDIT
|
||||
+ if (lflg) {
|
||||
+ audit_logger(AUDIT_ACCT_LOCK, "passwd",
|
||||
+ "locked-password",
|
||||
+ NULL, pw->pw_uid,
|
||||
+ ret ? SHADOW_AUDIT_SUCCESS : SHADOW_AUDIT_FAILURE);
|
||||
+ }
|
||||
+ if (uflg) {
|
||||
+ audit_logger(AUDIT_ACCT_UNLOCK, "passwd",
|
||||
+ "unlocked-password",
|
||||
+ NULL, pw->pw_uid,
|
||||
+ ret ? SHADOW_AUDIT_SUCCESS : SHADOW_AUDIT_FAILURE);
|
||||
+ }
|
||||
+ if (dflg) {
|
||||
+ audit_logger(AUDIT_USER_CHAUTHTOK, "passwd",
|
||||
+ "deleted-password",
|
||||
+ NULL, pw->pw_uid,
|
||||
+ ret ? SHADOW_AUDIT_SUCCESS : SHADOW_AUDIT_FAILURE);
|
||||
+ }
|
||||
+#endif /* WITH_AUDIT */
|
||||
+ if (ret == 0) {
|
||||
(void) fprintf (stderr,
|
||||
_("%s: failed to prepare the new %s entry '%s'\n"),
|
||||
Prog, pw_dbname (), npw->pw_name);
|
||||
@@ -599,8 +621,18 @@ static void update_noshadow (void)
|
||||
|
||||
static void update_shadow (void)
|
||||
{
|
||||
+ const struct passwd *pw;
|
||||
const struct spwd *sp;
|
||||
struct spwd *nsp;
|
||||
+ int ret;
|
||||
+
|
||||
+ pw = pw_locate(name);
|
||||
+ if (NULL == pw) {
|
||||
+ fprintf(stderr,
|
||||
+ _("%s: user '%s' does not exist in %s\n"),
|
||||
+ Prog, name, pw_dbname ());
|
||||
+ fail_exit (E_NOPERM);
|
||||
+ }
|
||||
|
||||
if (spw_lock () == 0) {
|
||||
(void) fprintf (stderr,
|
||||
@@ -691,7 +722,45 @@ static void update_shadow(bool process_selinux)
|
||||
nsp->sp_lstchg = 0;
|
||||
}
|
||||
|
||||
- if (spw_update (nsp) == 0) {
|
||||
+ ret = spw_update(nsp);
|
||||
+#ifdef WITH_AUDIT
|
||||
+ if (lflg) {
|
||||
+ audit_logger(AUDIT_ACCT_LOCK, "passwd",
|
||||
+ "locked-password",
|
||||
+ NULL, pw->pw_uid,
|
||||
+ ret ? SHADOW_AUDIT_SUCCESS : SHADOW_AUDIT_FAILURE);
|
||||
+ }
|
||||
+ if (uflg) {
|
||||
+ audit_logger(AUDIT_ACCT_UNLOCK, "passwd",
|
||||
+ "unlocked-password",
|
||||
+ NULL, pw->pw_uid,
|
||||
+ ret ? SHADOW_AUDIT_SUCCESS : SHADOW_AUDIT_FAILURE);
|
||||
+ }
|
||||
+ if (dflg) {
|
||||
+ audit_logger(AUDIT_USER_CHAUTHTOK, "passwd",
|
||||
+ "deleted-password",
|
||||
+ NULL, pw->pw_uid,
|
||||
+ ret ? SHADOW_AUDIT_SUCCESS : SHADOW_AUDIT_FAILURE);
|
||||
+ }
|
||||
+ if (eflg) {
|
||||
+ audit_logger(AUDIT_USER_MGMT, "passwd",
|
||||
+ "expired-password",
|
||||
+ NULL, pw->pw_uid,
|
||||
+ ret ? SHADOW_AUDIT_SUCCESS : SHADOW_AUDIT_FAILURE);
|
||||
+ }
|
||||
+ /* Audit aging parameter changes if any were modified */
|
||||
+ if (xflg || nflg || wflg || iflg) {
|
||||
+ char aging_msg[256];
|
||||
+ snprintf(aging_msg, sizeof(aging_msg),
|
||||
+ "changed-password-aging min=%ld max=%ld warn=%ld inact=%ld",
|
||||
+ nsp->sp_min, nsp->sp_max, nsp->sp_warn, nsp->sp_inact);
|
||||
+ audit_logger (AUDIT_USER_MGMT, "passwd",
|
||||
+ aging_msg,
|
||||
+ NULL, pw->pw_uid,
|
||||
+ ret ? SHADOW_AUDIT_SUCCESS : SHADOW_AUDIT_FAILURE);
|
||||
+ }
|
||||
+#endif /* WITH_AUDIT */
|
||||
+ if (ret == 0) {
|
||||
(void) fprintf (stderr,
|
||||
_("%s: failed to prepare the new %s entry '%s'\n"),
|
||||
Prog, spw_dbname (), nsp->sp_namp);
|
||||
@@ -755,6 +824,10 @@ main(int argc, char **argv)
|
||||
do_update_age = true;
|
||||
}
|
||||
|
||||
+#ifdef WITH_AUDIT
|
||||
+ audit_help_open();
|
||||
+#endif /* WITH_AUDIT */
|
||||
+
|
||||
/*
|
||||
* The program behaves differently when executed by root than when
|
||||
* executed by a normal user.
|
||||
@@ -987,6 +1060,12 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (anyflag && !amroot) {
|
||||
+#ifdef WITH_AUDIT
|
||||
+ audit_logger(AUDIT_USER_CHAUTHTOK, "passwd",
|
||||
+ "attempted-to-change-password-attribute",
|
||||
+ NULL, getuid(),
|
||||
+ SHADOW_AUDIT_FAILURE);
|
||||
+#endif /* WITH_AUDIT */
|
||||
(void) fprintf (stderr, _("%s: Permission denied.\n"), Prog);
|
||||
exit (E_NOPERM);
|
||||
}
|
||||
@@ -1002,6 +1081,12 @@ main(int argc, char **argv)
|
||||
/* only do this check when getuid()==0 because it's a pre-condition for
|
||||
changing a password without entering the old one */
|
||||
if (amroot && (check_selinux_permit (Prog) != 0)) {
|
||||
+#ifdef WITH_AUDIT
|
||||
+ audit_logger(AUDIT_USER_CHAUTHTOK, "passwd",
|
||||
+ "attempted-to-change-password",
|
||||
+ NULL, pw->pw_uid,
|
||||
+ SHADOW_AUDIT_FAILURE);
|
||||
+#endif /* WITH_AUDIT */
|
||||
SYSLOG ((LOG_ALERT,
|
||||
"root is not authorized by SELinux to change the password of %s",
|
||||
name));
|
||||
@@ -1017,6 +1102,12 @@ main(int argc, char **argv)
|
||||
* check if I'm root.
|
||||
*/
|
||||
if (!amroot && (pw->pw_uid != getuid ())) {
|
||||
+#ifdef WITH_AUDIT
|
||||
+ audit_logger(AUDIT_USER_CHAUTHTOK, "passwd",
|
||||
+ "attempted-to-change-password",
|
||||
+ NULL, pw->pw_uid,
|
||||
+ SHADOW_AUDIT_FAILURE);
|
||||
+#endif /* WITH_AUDIT */
|
||||
(void) fprintf (stderr,
|
||||
_("%s: You may not view or modify password information for %s.\n"),
|
||||
Prog, name);
|
||||
--
|
||||
2.53.0
|
||||
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
--- shadow-4.15.0/src/passwd.c.orig 2026-02-23 14:51:37.436277148 +0100
|
||||
+++ shadow-4.15.0/src/passwd.c 2026-02-23 14:53:17.130933320 +0100
|
||||
@@ -626,6 +626,20 @@
|
||||
struct spwd *nsp;
|
||||
int ret;
|
||||
|
||||
+ if (pw_lock () == 0) {
|
||||
+ (void) fprintf (stderr,
|
||||
+ _("%s: cannot lock %s; try again later.\n"),
|
||||
+ Prog, pw_dbname ());
|
||||
+ exit (E_PWDBUSY);
|
||||
+ }
|
||||
+ pw_locked = true;
|
||||
+ if (pw_open (O_CREAT | O_RDWR) == 0) {
|
||||
+ (void) fprintf (stderr,
|
||||
+ _("%s: cannot open %s\n"),
|
||||
+ Prog, pw_dbname ());
|
||||
+ SYSLOG ((LOG_WARN, "cannot open %s", pw_dbname ()));
|
||||
+ fail_exit (E_MISSING);
|
||||
+ }
|
||||
pw = pw_locate(name);
|
||||
if (NULL == pw) {
|
||||
fprintf(stderr,
|
||||
@@ -760,6 +774,22 @@
|
||||
/* continue */
|
||||
}
|
||||
spw_locked = false;
|
||||
+
|
||||
+ if (pw_close () == 0) {
|
||||
+ (void) fprintf (stderr,
|
||||
+ _("%s: failure while writing changes to %s\n"),
|
||||
+ Prog, pw_dbname ());
|
||||
+ SYSLOG ((LOG_ERR, "failure while writing changes to %s", pw_dbname ()));
|
||||
+ fail_exit (E_FAILURE);
|
||||
+ }
|
||||
+ if (pw_unlock () == 0) {
|
||||
+ (void) fprintf (stderr,
|
||||
+ _("%s: failed to unlock %s\n"),
|
||||
+ Prog, pw_dbname ());
|
||||
+ SYSLOG ((LOG_ERR, "failed to unlock %s", pw_dbname ()));
|
||||
+ /* continue */
|
||||
+ }
|
||||
+ pw_locked = false;
|
||||
}
|
||||
|
||||
/*
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,124 +0,0 @@
|
|||
From 67c42427a0941a4b47c04e8a95322be9d069ff32 Mon Sep 17 00:00:00 2001
|
||||
From: Alejandro Colomar <alx@kernel.org>
|
||||
Date: Tue, 15 Oct 2024 13:21:17 +0200
|
||||
Subject: [PATCH] lib/string/strcmp/: streq(): Add function
|
||||
|
||||
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
||||
---
|
||||
lib/subordinateio.c | 9 +++++----
|
||||
lib/Makefile.am | 2 ++
|
||||
lib/string/strcmp/streq.c | 12 ++++++++++++
|
||||
lib/string/strcmp/streq.h | 30 ++++++++++++++++++++++++++++++
|
||||
4 files changed, 44 insertions(+)
|
||||
create mode 100644 lib/string/strcmp/streq.c
|
||||
create mode 100644 lib/string/strcmp/streq.h
|
||||
|
||||
diff --git a/lib/subordinateio.c b/lib/subordinateio.c
|
||||
index 295df2bd..45085481 100644
|
||||
--- a/lib/subordinateio.c
|
||||
+++ b/lib/subordinateio.c
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include "alloc.h"
|
||||
#include "string/sprintf.h"
|
||||
+#include "string/strcmp/streq.h"
|
||||
|
||||
|
||||
#define ID_SIZE 31
|
||||
diff --git a/lib/Makefile.am b/lib/Makefile.am
|
||||
index 4ea5ec4e..96393354 100644
|
||||
--- a/lib/Makefile.am
|
||||
+++ b/lib/Makefile.am
|
||||
@@ -154,6 +154,8 @@ libshadow_la_SOURCES = \
|
||||
string/strtcpy.h \
|
||||
string/zustr2stp.c \
|
||||
string/zustr2stp.h \
|
||||
+ string/strcmp/streq.c \
|
||||
+ string/strcmp/streq.h \
|
||||
strtoday.c \
|
||||
sub.c \
|
||||
subordinateio.h \
|
||||
diff --git a/lib/string/strcmp/streq.c b/lib/string/strcmp/streq.c
|
||||
new file mode 100644
|
||||
index 00000000..52057ed8
|
||||
--- /dev/null
|
||||
+++ b/lib/string/strcmp/streq.c
|
||||
@@ -0,0 +1,12 @@
|
||||
+// SPDX-FileCopyrightText: 2024, Alejandro Colomar <alx@kernel.org>
|
||||
+// SPDX-License-Identifier: BSD-3-Clause
|
||||
+
|
||||
+
|
||||
+#include <config.h>
|
||||
+
|
||||
+#include <stdbool.h>
|
||||
+
|
||||
+#include "string/strcmp/streq.h"
|
||||
+
|
||||
+
|
||||
+extern inline bool streq(const char *s1, const char *s2);
|
||||
diff --git a/lib/string/strcmp/streq.h b/lib/string/strcmp/streq.h
|
||||
new file mode 100644
|
||||
index 00000000..267045c5
|
||||
--- /dev/null
|
||||
+++ b/lib/string/strcmp/streq.h
|
||||
@@ -0,0 +1,30 @@
|
||||
+// SPDX-FileCopyrightText: 2024, Alejandro Colomar <alx@kernel.org>
|
||||
+// SPDX-License-Identifier: BSD-3-Clause
|
||||
+
|
||||
+
|
||||
+#ifndef SHADOW_INCLUDE_LIB_STRING_STRCMP_STREQ_H_
|
||||
+#define SHADOW_INCLUDE_LIB_STRING_STRCMP_STREQ_H_
|
||||
+
|
||||
+
|
||||
+#include <config.h>
|
||||
+
|
||||
+#include <stdbool.h>
|
||||
+#include <string.h>
|
||||
+
|
||||
+#include "attr.h"
|
||||
+
|
||||
+
|
||||
+ATTR_STRING(1)
|
||||
+ATTR_STRING(2)
|
||||
+inline bool streq(const char *s1, const char *s2);
|
||||
+
|
||||
+
|
||||
+/* Return true if s1 and s2 compare equal. */
|
||||
+inline bool
|
||||
+streq(const char *s1, const char *s2)
|
||||
+{
|
||||
+ return strcmp(s1, s2) == 0;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+#endif // include guard
|
||||
--
|
||||
2.54.0
|
||||
|
||||
|
||||
diff -up shadow-4.15.0/lib/subordinateio.c.orig shadow-4.15.0/lib/subordinateio.c
|
||||
--- shadow-4.15.0/lib/subordinateio.c.orig 2026-05-14 15:54:21.131636830 +0200
|
||||
+++ shadow-4.15.0/lib/subordinateio.c 2026-05-14 15:54:35.544472143 +0200
|
||||
@@ -868,18 +868,10 @@ int list_owner_ranges(const char *owner,
|
||||
have_owner_id = get_owner_id(owner, id_type, id);
|
||||
|
||||
commonio_rewind(db);
|
||||
- while ((range = commonio_next(db)) != NULL) {
|
||||
- if (0 == strcmp(range->owner, owner)) {
|
||||
- if (!append_range(&ranges, range, count++)) {
|
||||
- free(ranges);
|
||||
- ranges = NULL;
|
||||
- count = -1;
|
||||
- goto out;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- // Let's also compare with the ID
|
||||
- if (have_owner_id == true && 0 == strcmp(range->owner, id)) {
|
||||
+ while (NULL != (range = commonio_next(db))) {
|
||||
+ if ( streq(range->owner, owner)
|
||||
+ || (have_owner_id && streq(range->owner, id)))
|
||||
+ {
|
||||
if (!append_range(&ranges, range, count++)) {
|
||||
free(ranges);
|
||||
ranges = NULL;
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
From 8903b94c86c978e8abef623358fd3e4629c06967 Mon Sep 17 00:00:00 2001
|
||||
From: Iker Pedrosa <ipedrosa@redhat.com>
|
||||
Date: Mon, 9 Sep 2024 10:36:17 +0200
|
||||
Subject: [PATCH] useradd: fix write_full() return value
|
||||
|
||||
write_full() returns -1 on error and useradd was checking another value.
|
||||
|
||||
Closes: https://github.com/shadow-maint/shadow/issues/1072
|
||||
Fixes: f45498a6c286 ("libmisc/write_full.c: Improve write_full()")
|
||||
|
||||
Reported-by: <https://github.com/brown-midas>
|
||||
Suggested-by: <https://github.com/brown-midas>
|
||||
Reviewed-by: Alejandro Colomar <alx@kernel.org>
|
||||
Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
|
||||
---
|
||||
src/useradd.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/useradd.c b/src/useradd.c
|
||||
index 02c500d0..d64fd892 100644
|
||||
--- a/src/useradd.c
|
||||
+++ b/src/useradd.c
|
||||
@@ -2042,7 +2042,7 @@ static void lastlog_reset (uid_t uid)
|
||||
return;
|
||||
}
|
||||
if ( (lseek (fd, offset_uid, SEEK_SET) != offset_uid)
|
||||
- || (write_full (fd, &ll, sizeof (ll)) != (ssize_t) sizeof (ll))
|
||||
+ || (write_full (fd, &ll, sizeof (ll)) == -1)
|
||||
|| (fsync (fd) != 0)) {
|
||||
fprintf (stderr,
|
||||
_("%s: failed to reset the lastlog entry of UID %lu: %s\n"),
|
||||
--
|
||||
2.46.0
|
||||
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
From 3b12ab7e29b0f3c766b39269da76a5ef3a753b22 Mon Sep 17 00:00:00 2001
|
||||
From: "Todd C. Miller" <Todd.Miller@sudo.ws>
|
||||
Date: Thu, 23 Jan 2025 19:11:09 -0700
|
||||
Subject: [PATCH] src/vipw.c: Restore the original terminal pgrp after editing
|
||||
|
||||
This fixes a problem when the shell is not in monitor mode (job control
|
||||
enabled) which resulted in the terminal pgrp being set to an invalid
|
||||
value once vipw exited.
|
||||
|
||||
Fixes: 7eca1112fbd7 (2019-11-11; "Fix vipw not resuming correctly when suspended")
|
||||
Closes: <https://github.com/shadow-maint/shadow/issues/1194>
|
||||
Reported-by: <https://github.com/yonecle>
|
||||
Tested-by: Alejandro Colomar <alx@kernel.org>
|
||||
Reviewed-by: Alejandro Colomar <alx@kernel.org>
|
||||
---
|
||||
src/vipw.c | 8 +++++++-
|
||||
1 file changed, 7 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/vipw.c b/src/vipw.c
|
||||
index a855e0d7..dbc87db9 100644
|
||||
--- a/src/vipw.c
|
||||
+++ b/src/vipw.c
|
||||
@@ -372,8 +372,14 @@ vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (void))
|
||||
}
|
||||
}
|
||||
|
||||
- if (orig_pgrp != -1)
|
||||
+ if (orig_pgrp != -1) {
|
||||
+ /* Restore terminal pgrp after editing. */
|
||||
+ if (tcsetpgrp(STDIN_FILENO, orig_pgrp) == -1) {
|
||||
+ fprintf(stderr, "%s: %s: %s", Prog,
|
||||
+ "tcsetpgrp", strerror(errno));
|
||||
+ }
|
||||
sigprocmask(SIG_SETMASK, &omask, NULL);
|
||||
+ }
|
||||
|
||||
if (-1 == pid) {
|
||||
vipwexit (editor, 1, 1);
|
||||
--
|
||||
2.49.0
|
||||
|
||||
69
shadow-4.2.1-date-parsing.patch
Normal file
69
shadow-4.2.1-date-parsing.patch
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
Index: shadow-4.5/libmisc/getdate.y
|
||||
===================================================================
|
||||
--- shadow-4.5.orig/libmisc/getdate.y
|
||||
+++ shadow-4.5/libmisc/getdate.y
|
||||
@@ -152,6 +152,7 @@ static int yyHaveDay;
|
||||
static int yyHaveRel;
|
||||
static int yyHaveTime;
|
||||
static int yyHaveZone;
|
||||
+static int yyHaveYear;
|
||||
static int yyTimezone;
|
||||
static int yyDay;
|
||||
static int yyHour;
|
||||
@@ -293,18 +294,21 @@ date : tUNUMBER '/' tUNUMBER {
|
||||
yyDay = $3;
|
||||
yyYear = $5;
|
||||
}
|
||||
+ yyHaveYear++;
|
||||
}
|
||||
| tUNUMBER tSNUMBER tSNUMBER {
|
||||
/* ISO 8601 format. yyyy-mm-dd. */
|
||||
yyYear = $1;
|
||||
yyMonth = -$2;
|
||||
yyDay = -$3;
|
||||
+ yyHaveYear++;
|
||||
}
|
||||
| tUNUMBER tMONTH tSNUMBER {
|
||||
/* e.g. 17-JUN-1992. */
|
||||
yyDay = $1;
|
||||
yyMonth = $2;
|
||||
yyYear = -$3;
|
||||
+ yyHaveYear++;
|
||||
}
|
||||
| tMONTH tUNUMBER {
|
||||
yyMonth = $1;
|
||||
@@ -314,6 +318,7 @@ date : tUNUMBER '/' tUNUMBER {
|
||||
yyMonth = $1;
|
||||
yyDay = $2;
|
||||
yyYear = $4;
|
||||
+ yyHaveYear++;
|
||||
}
|
||||
| tUNUMBER tMONTH {
|
||||
yyMonth = $2;
|
||||
@@ -323,6 +328,7 @@ date : tUNUMBER '/' tUNUMBER {
|
||||
yyMonth = $2;
|
||||
yyDay = $1;
|
||||
yyYear = $3;
|
||||
+ yyHaveYear++;
|
||||
}
|
||||
;
|
||||
|
||||
@@ -395,7 +401,8 @@ relunit : tUNUMBER tYEAR_UNIT {
|
||||
|
||||
number : tUNUMBER
|
||||
{
|
||||
- if ((yyHaveTime != 0) && (yyHaveDate != 0) && (yyHaveRel == 0))
|
||||
+ if ((yyHaveTime != 0 || $1 >= 100) && !yyHaveYear
|
||||
+ && (yyHaveDate != 0) && (yyHaveRel == 0))
|
||||
yyYear = $1;
|
||||
else
|
||||
{
|
||||
@@ -802,7 +809,7 @@ yylex (void)
|
||||
return LookupWord (buff);
|
||||
}
|
||||
if (c != '(')
|
||||
- return *yyInput++;
|
||||
+ return (unsigned char)*yyInput++;
|
||||
Count = 0;
|
||||
do
|
||||
{
|
||||
64
shadow-4.5-usermod-unlock.patch
Normal file
64
shadow-4.5-usermod-unlock.patch
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
Index: shadow-4.5/src/usermod.c
|
||||
===================================================================
|
||||
--- shadow-4.5.orig/src/usermod.c
|
||||
+++ shadow-4.5/src/usermod.c
|
||||
@@ -455,14 +455,17 @@ static char *new_pw_passwd (char *pw_pas
|
||||
strcat (buf, pw_pass);
|
||||
pw_pass = buf;
|
||||
} else if (Uflg && pw_pass[0] == '!') {
|
||||
- char *s;
|
||||
+ char *s = pw_pass;
|
||||
|
||||
- if (pw_pass[1] == '\0') {
|
||||
+ while ('!' == *s)
|
||||
+ ++s;
|
||||
+
|
||||
+ if (*s == '\0') {
|
||||
fprintf (stderr,
|
||||
_("%s: unlocking the user's password would result in a passwordless account.\n"
|
||||
"You should set a password with usermod -p to unlock this user's password.\n"),
|
||||
Prog);
|
||||
- return pw_pass;
|
||||
+ return NULL;
|
||||
}
|
||||
|
||||
#ifdef WITH_AUDIT
|
||||
@@ -471,12 +474,15 @@ static char *new_pw_passwd (char *pw_pas
|
||||
user_newname, (unsigned int) user_newid, 1);
|
||||
#endif
|
||||
SYSLOG ((LOG_INFO, "unlock user '%s' password", user_newname));
|
||||
- s = pw_pass;
|
||||
- while ('\0' != *s) {
|
||||
- *s = *(s + 1);
|
||||
- s++;
|
||||
- }
|
||||
+ memmove (pw_pass, s, strlen (s) + 1);
|
||||
} else if (pflg) {
|
||||
+ if (strchr (user_pass, ':') != NULL) {
|
||||
+ fprintf (stderr,
|
||||
+ _("%s: The password field cannot contain a colon character.\n"),
|
||||
+ Prog);
|
||||
+ return NULL;
|
||||
+
|
||||
+ }
|
||||
#ifdef WITH_AUDIT
|
||||
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
||||
"updating-password",
|
||||
@@ -525,6 +531,8 @@ static void new_pwent (struct passwd *pw
|
||||
if ( (!is_shadow_pwd)
|
||||
|| (strcmp (pwent->pw_passwd, SHADOW_PASSWD_STRING) != 0)) {
|
||||
pwent->pw_passwd = new_pw_passwd (pwent->pw_passwd);
|
||||
+ if (pwent->pw_passwd == NULL)
|
||||
+ fail_exit (E_PW_UPDATE);
|
||||
}
|
||||
|
||||
if (uflg) {
|
||||
@@ -639,6 +647,8 @@ static void new_spent (struct spwd *spen
|
||||
* + aging has been requested
|
||||
*/
|
||||
spent->sp_pwdp = new_pw_passwd (spent->sp_pwdp);
|
||||
+ if (spent->sp_pwdp == NULL)
|
||||
+ fail_exit(E_PW_UPDATE);
|
||||
|
||||
if (pflg) {
|
||||
spent->sp_lstchg = (long) gettime () / SCALE;
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue