RPM Package Manager, CVS Repository http://rpm5.org/cvs/ ____________________________________________________________________________
Server: rpm5.org Name: Jeff Johnson Root: /v/rpm/cvs Email: j...@rpm5.org Module: rpm Date: 10-May-2017 18:24:03 Branch: rpm-5_4 Handle: 2017051016240300 Modified files: (Branch: rpm-5_4) rpm CHANGES rpmqv.c system.h rpm/misc librpmmisc.c librpmmisc.vers setproctitle.c Log: - use setproctitle from glibc -lbsd (if possible). Summary: Revision Changes Path 1.3501.2.545+1 -0 rpm/CHANGES 1.5.4.2 +1 -1 rpm/misc/librpmmisc.c 1.35.2.15 +2 -2 rpm/misc/librpmmisc.vers 1.7.4.2 +43 -44 rpm/misc/setproctitle.c 1.167.4.13 +7 -7 rpm/rpmqv.c 2.129.2.22 +9 -8 rpm/system.h ____________________________________________________________________________ patch -p0 <<'@@ .' Index: rpm/CHANGES ============================================================================ $ cvs diff -u -r1.3501.2.544 -r1.3501.2.545 CHANGES --- rpm/CHANGES 5 May 2017 17:14:42 -0000 1.3501.2.544 +++ rpm/CHANGES 10 May 2017 16:24:03 -0000 1.3501.2.545 @@ -1,4 +1,5 @@ 5.4.17 -> 5.4.18: + - jbj: use setproctitle from glibc -lbsd (if possible). - jbj: cap: verify RPMTAG_FILECAPS if present and not disabled. - jbj: cap: attach RPMTAG_FILECAPS if present and not disabled. - jbj: cap: parse-and-add RPMTAG_FILECAPS. @@ . patch -p0 <<'@@ .' Index: rpm/misc/librpmmisc.c ============================================================================ $ cvs diff -u -r1.5.4.1 -r1.5.4.2 librpmmisc.c --- rpm/misc/librpmmisc.c 19 Jun 2016 06:48:47 -0000 1.5.4.1 +++ rpm/misc/librpmmisc.c 10 May 2017 16:24:03 -0000 1.5.4.2 @@ -33,7 +33,7 @@ #endif /* XXX limit the fiddle up to linux for now. */ -#if !defined(HAVE_SETPROCTITLE) && defined(__linux__) +#if defined(__linux__) #include "setproctitle.c" #endif @@ . patch -p0 <<'@@ .' Index: rpm/misc/librpmmisc.vers ============================================================================ $ cvs diff -u -r1.35.2.14 -r1.35.2.15 librpmmisc.vers --- rpm/misc/librpmmisc.vers 16 Jan 2017 18:58:06 -0000 1.35.2.14 +++ rpm/misc/librpmmisc.vers 10 May 2017 16:24:03 -0000 1.35.2.15 @@ -20,9 +20,9 @@ ficlSystemCreateVm; ficlSystemDestroy; ficlVmEvaluate; - finiproctitle; - initproctitle; setproctitle; + setproctitle_fini; + setproctitle_init; cmetrohash64_*; error_ref_sym; fb_*; @@ . patch -p0 <<'@@ .' Index: rpm/misc/setproctitle.c ============================================================================ $ cvs diff -u -r1.7.4.1 -r1.7.4.2 setproctitle.c --- rpm/misc/setproctitle.c 21 Mar 2016 23:20:13 -0000 1.7.4.1 +++ rpm/misc/setproctitle.c 10 May 2017 16:24:03 -0000 1.7.4.2 @@ -26,20 +26,19 @@ #include <sys/prctl.h> #endif -#if !defined(HAVE_SETPROCTITLE) - -static size_t title_buffer_size = 0; -static char *title_buffer = 0; +static size_t title_buffer_size; +static char *title_buffer; static char *title_progname; static char *title_progname_full; -int +#if !defined(HAVE_SETPROCTITLE) +void setproctitle(const char *fmt, ...) { if (!title_buffer || !title_buffer_size) { errno = ENOMEM; - return -1; + return; } memset(title_buffer, '\0', title_buffer_size); @@ -55,7 +54,7 @@ snprintf(title_buffer, title_buffer_size, "%s: ", title_progname); if (written < 0 || (size_t) written >= title_buffer_size) - return -1; + return; va_start(ap, fmt); written2 = @@ -64,14 +63,14 @@ va_end(ap); if (written2 < 0 || (size_t) written2 >= title_buffer_size - written) - return -1; + return; } else { written = snprintf(title_buffer, title_buffer_size, "%s", title_progname); if (written < 0 || (size_t) written >= title_buffer_size) - return -1; + return; } written = strlen(title_buffer); @@ -92,39 +91,10 @@ } #endif - return 0; } -/* - * Rename to _init/_fini for automagic ELF weak symbol library symbol override. - * Note: __attribute__((constructor)) on _init function is - * called without arguments. - */ - -int -finiproctitle(void) -{ -/* XXX limit the fiddle up to linux for now. */ -#if defined(__linux__) - if (title_buffer != NULL) { - char ** envp; - for (envp = environ; *envp != NULL; envp++) { - free(*envp); - *envp = NULL; - } - free(environ); - environ = NULL; -#ifdef DYING /* XXX mongoc test routines segfault on exit w valgrind */ - free(title_progname_full); -#endif - title_progname_full = NULL; - } -#endif - return 0; -} - -int -initproctitle(int argc, char *argv[], char *envp[]) +void +setproctitle_init(int argc, char *argv[], char *envp[]) { /* XXX limit the fiddle up to linux for now. */ @@ -149,12 +119,12 @@ } if (!end_of_buffer) - return 0; + return; char **new_environ = (char **) malloc((i + 1) * sizeof(envp[0])); if (!new_environ) - return 0; + return; for (i = 0; envp[i]; ++i) if (!(new_environ[i] = strdup(envp[i]))) @@ -183,13 +153,42 @@ title_buffer = begin_of_buffer; title_buffer_size = end_of_buffer - begin_of_buffer; - return 0; + return; cleanup_enomem: for (--i; i >= 0; --i) free(new_environ[i]); free(new_environ); #endif /* defined(__linux__) */ - return 0; + return; } #endif /* !defined(HAVE_SETPROCTITLE) */ + +/* + * Rename to _init/_fini for automagic ELF weak symbol library symbol override. + * Note: __attribute__((constructor)) on _init function is + * called without arguments. + */ + +void +setproctitle_fini(void) +{ +/* XXX limit the fiddle up to linux for now. */ +#if defined(__linux__) + if (title_buffer != NULL) { + char ** envp; + for (envp = environ; *envp != NULL; envp++) { + free(*envp); + *envp = NULL; + } + free(environ); + environ = NULL; +#ifdef DYING /* XXX mongoc test routines segfault on exit w valgrind */ + free(title_progname_full); +#endif + title_buffer_size = 0; + title_progname_full = NULL; + title_progname = NULL; + } +#endif +} @@ . patch -p0 <<'@@ .' Index: rpm/rpmqv.c ============================================================================ $ cvs diff -u -r1.167.4.12 -r1.167.4.13 rpmqv.c --- rpm/rpmqv.c 28 Mar 2016 19:12:14 -0000 1.167.4.12 +++ rpm/rpmqv.c 10 May 2017 16:24:03 -0000 1.167.4.13 @@ -450,9 +450,9 @@ /*@-bounds@*/ /* LCL: segfault */ /*@-mods@*/ /* FIX: shrug */ #if !defined(__GLIBC__) && !defined(__LCLINT__) -int main(int argc, const char ** argv, /*@unused@*/ char ** envp) +int main(int argc, char *argv[], /*@unused@*/ char ** envp) #else -int main(int argc, const char ** argv) +int main(int argc, char *argv[]) #endif /*@globals rpmEVR, RPMVERSION, rpmGlobalMacroContext, rpmCLIMacroContext, @@ -500,8 +500,8 @@ environ = envp; #else /* XXX limit the fiddle up to linux for now. */ -#if !defined(HAVE_SETPROCTITLE) && defined(__linux__) - (void) initproctitle(argc, (char **)argv, environ); +#if defined(__linux__) + setproctitle_init(argc, argv, environ); #endif #endif @@ -1165,15 +1165,15 @@ optCon = rpmcliFini(optCon); /* XXX limit the fiddle up to linux for now. */ -#if !defined(HAVE_SETPROCTITLE) && defined(__linux__) - (void) finiproctitle(); +#if defined(__linux__) + setproctitle_fini(); #endif /* XXX don't overflow single byte exit status */ /* XXX status 255 is special to xargs(1) */ if (ec > 254) ec = 254; - rpmlog(RPMLOG_DEBUG, D_("exit code: %d\n"), ec); + rpmlog(RPMLOG_DEBUG, D_("exit code: %d\n"), ec); /*@-globstate@*/ return ec; @@ . patch -p0 <<'@@ .' Index: rpm/system.h ============================================================================ $ cvs diff -u -r2.129.2.21 -r2.129.2.22 system.h --- rpm/system.h 23 Dec 2016 16:51:37 -0000 2.129.2.21 +++ rpm/system.h 10 May 2017 16:24:03 -0000 2.129.2.22 @@ -402,18 +402,19 @@ /*@*/; /* XXX limit the fiddle up to linux for now. */ -#if !defined(HAVE_SETPROCTITLE) && defined(__linux__) -extern int finiproctitle(void) +#if defined(__linux__) +extern void setproctitle (const char *fmt, ...) + __attribute__ ((__format__ (__printf__, 1, 2))) + /*@*/; + +extern void setproctitle_init(int argc, char *argv[], char *envp[]) /*@globals environ @*/ /*@modifies environ @*/; -extern int initproctitle(int argc, char *argv[], char *envp[]) + +extern void setproctitle_fini(void) __attribute__((__const__)) /*@globals environ @*/ /*@modifies environ @*/; - -extern int setproctitle (const char *fmt, ...) - __attribute__ ((__format__ (__printf__, 1, 2))) - /*@*/; -#endif /* !defined(HAVE_SETPROCTITLE) && defined(__linux__) */ +#endif /* defined(__linux__) */ #ifdef __cplusplus } @@ . ______________________________________________________________________ RPM Package Manager http://rpm5.org CVS Sources Repository rpm-cvs@rpm5.org