Группа :: Система/Настройка/Загрузка и инициализация
Пакет: sysvinit
Главная Изменения Спек Патчи Sources Загрузить Gear Bugs and FR Repocop
Патч: 0001-ALT-Use-program_invocation_short_name-as-progname.patch
Скачать
Скачать
From 4fe7acee2cd097ecbdb44e515356026a3ea7ed58 Mon Sep 17 00:00:00 2001
From: Alexey Gladkov <legion@altlinux.org>
Date: Thu, 16 Dec 2021 18:16:32 +0300
Subject: ALT: Use program_invocation_short_name as progname
---
src/halt.c | 10 ++++------
src/init.c | 13 ++++---------
src/killall5.c | 8 +-------
src/last.c | 4 +---
4 files changed, 10 insertions(+), 25 deletions(-)
diff --git a/src/halt.c b/src/halt.c
index a469147..5f1d98f 100644
--- a/src/halt.c
+++ b/src/halt.c
@@ -55,12 +55,13 @@
#include <time.h>
#include <signal.h>
#include <stdio.h>
+#include <errno.h>
#include <getopt.h>
#include "reboot.h"
#include "runlevellog.h"
char *Version = "@(#)halt 2.86 31-Jul-2004 miquels@cistron.nl";
-char *progname;
+const char *progname;
#define KERNEL_MONITOR 1 /* If halt() puts you into the kernel monitor. */
#define RUNLVL_PICKY 0 /* Be picky about the runlevel */
@@ -199,12 +200,9 @@ int main(int argc, char **argv)
/*
* Find out who we are
*/
+ progname = program_invocation_short_name;
/* Remove dash passed on in argv[0] when used as login shell. */
- if (argv[0][0] == '-') argv[0]++;
- if ((progname = strrchr(argv[0], '/')) != NULL)
- progname++;
- else
- progname = argv[0];
+ if (progname[0] == '-') progname++;
if (!strcmp(progname, "reboot")) do_reboot = 1;
if (!strcmp(progname, "poweroff")) do_poweroff = 1;
diff --git a/src/init.c b/src/init.c
index 16d45c3..92c1877 100644
--- a/src/init.c
+++ b/src/init.c
@@ -3084,19 +3084,12 @@ int telinit(char *progname, int argc, char **argv)
*/
int main(int argc, char **argv)
{
- char *p;
int f;
int isinit;
#ifdef WITH_SELINUX
int enforce = 0;
#endif
- /* Get my own name */
- if ((p = strrchr(argv[0], '/')) != NULL)
- p++;
- else
- p = argv[0];
-
if ( (argc == 2) && (! strcmp(argv[1], "--version") ) )
{
printf("SysV init version: %s\n\n", VERSION);
@@ -3108,7 +3101,8 @@ int main(int argc, char **argv)
/* Quick check */
if (geteuid() != 0) {
- fprintf(stderr, "%s: must be superuser.\n", p);
+ fprintf(stderr, "%s: must be superuser.\n",
+ program_invocation_short_name);
exit(1);
}
@@ -3122,7 +3116,8 @@ int main(int argc, char **argv)
break;
}
}
- if (!isinit) exit(telinit(p, argc, argv));
+ if (!isinit)
+ exit(telinit(program_invocation_short_name, argc, argv));
/*
* Check for re-exec
diff --git a/src/killall5.c b/src/killall5.c
index 22d29dc..c0fea9c 100644
--- a/src/killall5.c
+++ b/src/killall5.c
@@ -146,7 +146,7 @@ int scripts_too = 0;
#endif
int list_dz_processes = FALSE;
-char *progname; /* the name of the running program */
+#define progname program_invocation_short_name
#ifdef __GNUC__
__attribute__ ((format (printf, 2, 3)))
#endif
@@ -1155,12 +1155,6 @@ int main(int argc, char **argv)
/* return non-zero if no process was killed */
int retval = 2;
- /* Get program name. */
- if ((progname = strrchr(argv[0], '/')) == NULL)
- progname = argv[0];
- else
- progname++;
-
/* Now connect to syslog. */
openlog(progname, LOG_CONS|LOG_PID, LOG_DAEMON);
diff --git a/src/last.c b/src/last.c
index 1c028cc..2591164 100644
--- a/src/last.c
+++ b/src/last.c
@@ -90,7 +90,7 @@ int oldfmt = 0; /* Use old libc5 format? */
char **show = NULL; /* What do they want us to show */
char *ufile; /* Filename of this file */
time_t lastdate; /* Last date we've seen */
-char *progname; /* Name of this program */
+#define progname program_invocation_short_name
#if CHOP_DOMAIN
char hostname[256]; /* For gethostbyname() */
char *domainname; /* Our domainname. */
@@ -641,8 +641,6 @@ int main(int argc, char **argv)
time_t until = 0; /* at what time to stop parsing the file */
- progname = mybasename(argv[0]);
-
/* Process the arguments. */
while((c = getopt(argc, argv, "f:n:RxadFliot:0123456789w")) != EOF)
switch(c) {
--
2.25.4