Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package procps4 for openSUSE:Factory checked in at 2023-08-18 19:29:08 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/procps4 (Old) and /work/SRC/openSUSE:Factory/.procps4.new.1766 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "procps4" Fri Aug 18 19:29:08 2023 rev:5 rq:1104662 version:4.0.3 Changes: -------- --- /work/SRC/openSUSE:Factory/procps4/procps4.changes 2023-08-17 19:44:58.798950355 +0200 +++ /work/SRC/openSUSE:Factory/.procps4.new.1766/procps4.changes 2023-08-18 19:29:43.539462938 +0200 @@ -1,0 +2,13 @@ +Fri Aug 18 11:10:05 UTC 2023 - Dr. Werner Fink <[email protected]> + +- Modify patch procps-ng-3.3.9-w-notruncate.diff + to real to not truncate output of w with option -n + +------------------------------------------------------------------- +Thu Aug 17 12:49:41 UTC 2023 - Thorsten Kukuk <[email protected]> + +- procps-ng-4.0.3-logind.patch: Backport from 4.x git, prefer + logind over utmp (jsc#PED-3144) +- procps-ng-3.3.9-w-notruncate.diff: Rebase + +------------------------------------------------------------------- New: ---- procps-ng-4.0.3-logind.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ procps4.spec ++++++ --- /var/tmp/diff_new_pack.VQsKnA/_old 2023-08-18 19:29:44.571464789 +0200 +++ /var/tmp/diff_new_pack.VQsKnA/_new 2023-08-18 19:29:44.579464803 +0200 @@ -60,6 +60,7 @@ Patch37: procps-ng-4.0.0-floats.dif # PATCH-FIX-UPSTREAM -- bsc#1214290 Patch38: CVE-2023-4016.patch +Patch39: procps-ng-4.0.3-logind.patch BuildRequires: automake BuildRequires: dejagnu BuildRequires: diffutils @@ -133,7 +134,8 @@ %prep %setup -q -n procps-ng-%{version} %patch1 -%patch3 -b .trcate +%patch39 -p1 +%patch3 -p1 -b .trcate %patch7 -b .rof %patch8 -b .cache %patch11 ++++++ procps-ng-3.3.9-w-notruncate.diff ++++++ --- /var/tmp/diff_new_pack.VQsKnA/_old 2023-08-18 19:29:44.671464968 +0200 +++ /var/tmp/diff_new_pack.VQsKnA/_new 2023-08-18 19:29:44.675464975 +0200 @@ -1,10 +1,10 @@ --- - man/w.1 | 3 +++ - src/w.c | 18 +++++++++++++++--- - 2 files changed, 18 insertions(+), 3 deletions(-) + procps-ng-4.0.3/man/w.1 | 3 +++ + procps-ng-4.0.3/src/w.c | 27 +++++++++++++++++++++++---- + 2 files changed, 26 insertions(+), 4 deletions(-) ---- man/w.1 -+++ man/w.1 2023-02-08 08:51:13.971987652 +0000 +--- procps-ng-4.0.3/man/w.1 ++++ procps-ng-4.0.3/man/w.1 2023-08-18 11:06:24.615573481 +0000 @@ -51,6 +51,9 @@ and a \fB\-s\fR, \fB\-\-short\fR Use the short format. Don't print the login time, JCPU or PCPU times. @@ -15,33 +15,49 @@ \fB\-f\fR, \fB\-\-from\fR Toggle printing the .B from ---- src/w.c -+++ src/w.c 2023-02-08 08:53:39.785313401 +0000 -@@ -458,7 +458,7 @@ static int find_best_proc( - - static void showinfo( +--- procps-ng-4.0.3/src/w.c ++++ procps-ng-4.0.3/src/w.c 2023-08-18 11:06:24.615573481 +0000 +@@ -217,7 +217,8 @@ static void print_from( + if (r < 0 || host == NULL) + print_host("", 0, fromlen); + else { +- print_host(host, strlen(host), fromlen); ++ print_host(host, strlen(host), ++ fromlen == 0?strlen(host):fromlen); + free(host); + } + } else { +@@ -510,7 +511,7 @@ static void showinfo( + const char *session, const char *name, + #endif utmp_t * u, int formtype, int maxcmd, int from, - const int userlen, const int fromlen, const int ip_addresses, + int userlen, int fromlen, const int ip_addresses, const int pids) { unsigned long long jcpu, pcpu; -@@ -492,7 +492,13 @@ static void showinfo( - strncpy(uname, u->ut_user, UT_NAMESIZE); +@@ -574,7 +575,19 @@ static void showinfo( + uname[UT_NAMESIZE] = '\0'; if (formtype) { -- printf("%-*.*s%-9.8s", userlen + 1, userlen, uname, u->ut_line); -+ int utlnlen = 8; +- printf("%-*.*s%-9.8s", userlen + 1, userlen, uname, tty+5); ++ int utlnlen = 8; + if (formtype > 1) { + userlen = strnlen(uname, UT_NAMESIZE); -+ fromlen = strnlen(u->ut_host, UT_HOSTSIZE); -+ utlnlen = strnlen(u->ut_line, UT_LINESIZE); ++ if (u) { ++ fromlen = strnlen(u->ut_host, UT_HOSTSIZE); ++ utlnlen = strnlen(u->ut_line, UT_LINESIZE); ++ } else { ++ fromlen = 0; ++ utlnlen = strlen (tty+5); ++ } ++ maxcmd = MAX_CMD_WIDTH; + } -+ printf("%-*.*s%-*.*s", userlen + 1, userlen, uname, utlnlen + 1, utlnlen, u->ut_line); - if (from) - print_from(u, ip_addresses, fromlen); - #ifdef HAVE_UTMPX_H -@@ -545,6 +551,7 @@ static void __attribute__ ((__noreturn__ ++ printf("%-*.*s%-*.*s", userlen + 1, userlen, uname, utlnlen + 1, utlnlen, tty+5); + #if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && defined(HAVE_SD_SESSION_GET_LEADER) + if (session) { + uint64_t ltime; +@@ -657,6 +670,7 @@ static void __attribute__ ((__noreturn__ fputs(_(" -h, --no-header do not print header\n"),out); fputs(_(" -u, --no-current ignore current process username\n"),out); fputs(_(" -s, --short short format\n"),out); @@ -49,7 +65,7 @@ fputs(_(" -f, --from show remote hostname field\n"),out); fputs(_(" -o, --old-style old style output\n"),out); fputs(_(" -i, --ip-addr display IP address instead of hostname (if possible)\n"), out); -@@ -583,6 +590,7 @@ int main(int argc, char **argv) +@@ -695,6 +709,7 @@ int main(int argc, char **argv) {"no-header", no_argument, NULL, 'h'}, {"no-current", no_argument, NULL, 'u'}, {"short", no_argument, NULL, 's'}, @@ -57,7 +73,7 @@ {"from", no_argument, NULL, 'f'}, {"old-style", no_argument, NULL, 'o'}, {"ip-addr", no_argument, NULL, 'i'}, -@@ -605,7 +613,7 @@ int main(int argc, char **argv) +@@ -717,7 +732,7 @@ int main(int argc, char **argv) #endif while ((ch = @@ -66,7 +82,7 @@ switch (ch) { case 'h': header = 0; -@@ -613,6 +621,10 @@ int main(int argc, char **argv) +@@ -725,6 +740,10 @@ int main(int argc, char **argv) case 's': longform = 0; break; ++++++ procps-ng-4.0.3-logind.patch ++++++ diff -ur procps-ng-4.0.3/configure.ac procps-ng-4.0.3-logind/configure.ac --- procps-ng-4.0.3/configure.ac 2023-01-20 05:09:50.384554951 +0100 +++ procps-ng-4.0.3-logind/configure.ac 2023-08-16 14:55:01.029867162 +0200 @@ -270,6 +270,13 @@ [PKG_CHECK_MODULES([SYSTEMD], [libsystemd-login])] ) AC_DEFINE(WITH_SYSTEMD, 1, [enable systemd support]) + + # The functions needed to replace utmp with logind are only available + # with systemd v254 or later. + old_LIBS="$LIBS" + LIBS="$LIBS $SYSTEMD_LIBS" + AC_CHECK_FUNCS([sd_session_get_leader]) + LIBS="$old_LIBS" ]) AM_CONDITIONAL([WITH_SYSTEMD], [test x$with_systemd != xno]) diff -ur procps-ng-4.0.3/library/uptime.c procps-ng-4.0.3-logind/library/uptime.c --- procps-ng-4.0.3/library/uptime.c 2023-02-06 23:56:56.219274319 +0100 +++ procps-ng-4.0.3-logind/library/uptime.c 2023-08-16 14:55:01.029867162 +0200 @@ -31,6 +31,14 @@ #include <time.h> #include <unistd.h> #include <utmp.h> +#ifdef WITH_SYSTEMD +#include <systemd/sd-daemon.h> +#include <systemd/sd-login.h> +#endif +#ifdef WITH_ELOGIND +#include <elogind/sd-daemon.h> +#include <elogind/sd-login.h> +#endif #include "misc.h" #include "procps-private.h" @@ -45,6 +53,11 @@ int numuser = 0; struct utmp *ut; +#if defined(WITH_SYSTEMD) || defined(WITH_ELOGIND) + if (sd_booted() > 0) + return sd_get_sessions(NULL); +#endif + setutent(); while ((ut = getutent())) { if ((ut->ut_type == USER_PROCESS) && (ut->ut_name[0] != '\0')) @@ -136,8 +149,13 @@ users = count_users(); procps_loadavg(&av1, &av5, &av15); - pos += sprintf(upbuf + pos, "%2d %s, load average: %.2f, %.2f, %.2f", - users, users > 1 ? "users" : "user", + if (users < 0) + pos += sprintf(upbuf + pos, " ? "); + else + pos += sprintf(upbuf + pos, "%2d ", users); + + pos += sprintf(upbuf + pos, "%s, load average: %.2f, %.2f, %.2f", + users > 1 ? "users" : "user", av1, av5, av15); return upbuf; @@ -248,4 +266,3 @@ } return shortbuf; } - diff -ur procps-ng-4.0.3/src/w.c procps-ng-4.0.3-logind/src/w.c --- procps-ng-4.0.3/src/w.c 2023-02-13 21:24:25.924831319 +0100 +++ procps-ng-4.0.3-logind/src/w.c 2023-08-17 14:52:19.647761317 +0200 @@ -52,6 +52,14 @@ # include <utmp.h> #endif #include <arpa/inet.h> +#ifdef WITH_SYSTEMD +# include <systemd/sd-login.h> +# include <systemd/sd-daemon.h> +#endif +#ifdef WITH_ELOGIND +# include <elogind/sd-login.h> +# include <elogind/sd-daemon.h> +#endif #include "c.h" #include "fileutils.h" @@ -195,7 +203,25 @@ /* This routine prints either the hostname or the IP address of the remote */ -static void print_from(const utmp_t *restrict const u, const int ip_addresses, const int fromlen) { +static void print_from( +#if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && defined(HAVE_SD_SESSION_GET_LEADER) + const char *session, +#endif + const utmp_t *restrict const u, const int ip_addresses, const int fromlen) { +#if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && defined(HAVE_SD_SESSION_GET_LEADER) + if (session) { + char *host = NULL; + int r; + + r = sd_session_get_remote_host(session, &host); + if (r < 0 || host == NULL) + print_host("", 0, fromlen); + else { + print_host(host, strlen(host), fromlen); + free(host); + } + } else { +#endif char buf[fromlen + 1]; char buf_ipv6[INET6_ADDRSTRLEN]; int len; @@ -240,6 +266,9 @@ #else print_host(u->ut_host, UT_HOSTSIZE, fromlen); #endif +#if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && defined(HAVE_SD_SESSION_GET_LEADER) + } +#endif } @@ -342,7 +371,7 @@ for (i=0; dev_paths[i] != NULL; i++) { snprintf(buf, 32, dev_paths[i], name); - if (stat(buf, &st) == 0) + if (stat(buf, &st) == 0 && (st.st_mode & S_IFMT) == S_IFCHR) return st.st_rdev; } return -1; @@ -356,6 +385,9 @@ * essential core of 'w'. */ static int find_best_proc( +#if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && defined(HAVE_SD_SESSION_GET_LEADER) + const char *session, +#endif const utmp_t * restrict const u, const char *restrict const tty, unsigned long long *restrict const jcpu, @@ -368,6 +400,7 @@ #define PIDS_GETULL(e) PIDS_VAL(EU_ ## e, ull_int, reap->stacks[i], info) #define PIDS_GETSTR(e) PIDS_VAL(EU_ ## e, str, reap->stacks[i], info) unsigned uid = ~0U; + pid_t ut_pid = -1; int found_utpid = 0; int i, total_procs, line; unsigned long long best_time = 0; @@ -393,6 +426,12 @@ *jcpu = 0; *pcpu = 0; if (!ignoreuser) { +#if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && defined(HAVE_SD_SESSION_GET_LEADER) + if (session) { + if (sd_session_get_uid(session, &uid) < 0) + return 0; + } else { +#endif char buf[UT_NAMESIZE + 1]; struct passwd *passwd_data; strncpy(buf, u->ut_user, UT_NAMESIZE); @@ -401,6 +440,9 @@ return 0; uid = passwd_data->pw_uid; /* OK to have passwd_data go out of scope here */ +#if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && defined(HAVE_SD_SESSION_GET_LEADER) + } +#endif } line = get_tty_device(tty); @@ -413,9 +455,16 @@ _("Unable to load process information")); total_procs = reap->counts->total; + if (u) + ut_pid = u->ut_pid; +#if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && defined(HAVE_SD_SESSION_GET_LEADER) + else + sd_session_get_leader(session, &ut_pid); +#endif + for (i=0; i < total_procs; i++) { /* is this the login process? */ - if (PIDS_GETINT(TGID) == u->ut_pid) { + if (PIDS_GETINT(TGID) == ut_pid) { found_utpid = 1; if (!best_time) { best_time = PIDS_GETULL(START); @@ -457,6 +506,9 @@ } static void showinfo( +#if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && defined(HAVE_SD_SESSION_GET_LEADER) + const char *session, const char *name, +#endif utmp_t * u, int formtype, int maxcmd, int from, const int userlen, const int fromlen, const int ip_addresses, const int pids) @@ -472,14 +524,37 @@ strcpy(cmdline, "-"); hertz = procps_hertz_get(); + +#if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && defined(HAVE_SD_SESSION_GET_LEADER) + if (session) { + char *sd_tty; + + if (sd_session_get_tty(session, &sd_tty) >= 0) { + for (i = 0; i < strlen (sd_tty); i++) + /* clean up tty if garbled */ + if (isalnum(sd_tty[i]) || (sd_tty[i] == '/')) + tty[i + 5] = sd_tty[i]; + else + tty[i + 5] = '\0'; + free(sd_tty); + } + } else { +#endif for (i = 0; i < UT_LINESIZE; i++) /* clean up tty if garbled */ if (isalnum(u->ut_line[i]) || (u->ut_line[i] == '/')) tty[i + 5] = u->ut_line[i]; else tty[i + 5] = '\0'; +#if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && defined(HAVE_SD_SESSION_GET_LEADER) + } +#endif - if (find_best_proc(u, tty + 5, &jcpu, &pcpu, cmdline, &best_pid) == 0) + if (find_best_proc( +#if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && defined(HAVE_SD_SESSION_GET_LEADER) + session, +#endif + u, tty + 5, &jcpu, &pcpu, cmdline, &best_pid) == 0) /* * just skip if stale utmp entry (i.e. login proc doesn't * exist). If there is a desire a cmdline flag could be @@ -488,19 +563,45 @@ */ return; - /* force NUL term for printf */ + +#if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && defined(HAVE_SD_SESSION_GET_LEADER) + if (name) + strncpy(uname, name, UT_NAMESIZE); + else +#endif strncpy(uname, u->ut_user, UT_NAMESIZE); + /* force NUL term for printf */ + uname[UT_NAMESIZE] = '\0'; if (formtype) { - printf("%-*.*s%-9.8s", userlen + 1, userlen, uname, u->ut_line); - if (from) - print_from(u, ip_addresses, fromlen); + printf("%-*.*s%-9.8s", userlen + 1, userlen, uname, tty+5); +#if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && defined(HAVE_SD_SESSION_GET_LEADER) + if (session) { + uint64_t ltime; + + if (from) + print_from(session, NULL, ip_addresses, fromlen); + + sd_session_get_start_time(session, <ime); + print_logintime(ltime/((uint64_t) 1000000ULL), stdout); + } else { +#endif + if (from) + print_from( +#if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && defined(HAVE_SD_SESSION_GET_LEADER) + NULL, +#endif + u, ip_addresses, fromlen); + #ifdef HAVE_UTMPX_H print_logintime(u->ut_tv.tv_sec, stdout); #else print_logintime(u->ut_time, stdout); #endif - if (*u->ut_line == ':') +#if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && defined(HAVE_SD_SESSION_GET_LEADER) + } +#endif + if (u && *u->ut_line == ':') /* idle unknown for xdm logins */ printf(" ?xdm? "); else @@ -517,15 +618,26 @@ printf("%-*.*s%-9.8s", userlen + 1, userlen, u->ut_user, u->ut_line); if (from) - print_from(u, ip_addresses, fromlen); - if (*u->ut_line == ':') + print_from( +#if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && defined(HAVE_SD_SESSION_GET_LEADER) + NULL, +#endif + u, ip_addresses, fromlen); + if (u && *u->ut_line == ':') /* idle unknown for xdm logins */ printf(" ?xdm? "); else print_time_ival7(idletime(tty), 0, stdout); } if (pids) { - pids_length = printf(" %d/%d", u->ut_pid, best_pid); + pid_t ut_pid = -1; + if (u) + ut_pid = u->ut_pid; +#if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && defined(HAVE_SD_SESSION_GET_LEADER) + else + sd_session_get_leader(session, &ut_pid); +#endif + pids_length = printf(" %d/%d", ut_pid, best_pid); if (pids_length > maxcmd) { maxcmd = 0; } else if (pids_length > 0) { @@ -691,7 +803,40 @@ else printf(_(" IDLE WHAT\n")); } - +#if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && defined(HAVE_SD_SESSION_GET_LEADER) + if (sd_booted() > 0) { + char **sessions_list; + int sessions; + int i; + + sessions = sd_get_sessions (&sessions_list); + if (sessions < 0 && sessions != -ENOENT) + error(EXIT_FAILURE, -sessions, _("error getting sessions")); + + if (sessions >= 0) { + for (int i = 0; i < sessions; i++) { + char *name; + int r; + + if ((r = sd_session_get_username(sessions_list[i], &name)) < 0) + error(EXIT_FAILURE, -r, _("get user name failed")); + + if (user) { + if (!strcmp(name, user)) + showinfo(sessions_list[i], name, NULL, longform, + maxcmd, from, userlen, fromlen, + ip_addresses, pids); + } else { + showinfo(sessions_list[i], name, NULL, longform, maxcmd, + from, userlen, fromlen, ip_addresses, pids); + } + free(name); + free(sessions_list[i]); + } + free(sessions_list); + } + } else { +#endif #ifdef HAVE_UTMPX_H setutxent(); #else @@ -710,7 +855,11 @@ if (u->ut_type != USER_PROCESS) continue; if (!strncmp(u->ut_user, user, UT_NAMESIZE)) - showinfo(u, longform, maxcmd, from, userlen, + showinfo( +#if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && defined(HAVE_SD_SESSION_GET_LEADER) + NULL, NULL, +#endif + u, longform, maxcmd, from, userlen, fromlen, ip_addresses, pids); } } else { @@ -725,7 +874,11 @@ if (u->ut_type != USER_PROCESS) continue; if (*u->ut_user) - showinfo(u, longform, maxcmd, from, userlen, + showinfo( +#if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && defined(HAVE_SD_SESSION_GET_LEADER) + NULL, NULL, +#endif + u, longform, maxcmd, from, userlen, fromlen, ip_addresses, pids); } } @@ -734,6 +887,9 @@ #else endutent(); #endif +#if (defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)) && defined(HAVE_SD_SESSION_GET_LEADER) + } +#endif return EXIT_SUCCESS; }
