RPM Community Forums

Mailing List Message of <rpm-devel>

Re: [CVS] RPM: rpm-5_1: lua/shadow/ copydir.c list.c strtoday.c useradd.c ...

From: Jeff Johnson <n3npq@mac.com>
Date: Mon 27 Oct 2008 - 01:46:05 CET
Message-id: <649BFC25-706B-4B61-9E85-663AAAC138D5@mac.com>
This patch preserves the forward linkage necessary to use -pie
when assembling librpmmisc*.so.

The only remaining fix to avoid the dreaded SELinux avc message
when using the "Danger Will Robinson! Eat my kittens!" rpm-5.1.x
releases is to arrange for -pie -nostartfiles to be added with
librpmmisc AutoFu somehow.

Ralf: Could I get a little help adding the flags please? I mean
I can likely arrange for two flags to be added myself, but the
consequences might be sub-optimal.

Here's the linkage line that passes the eu-findtestrel test:

gcc -shared -pie -nostartfiles .libs/librpmmisc.o -Wl,--whole-archive / 
X/src/wdj51/db3/.libs/libdb-4.7.a /X/src/wdj51/lua/.libs/liblua.a /X/ 
src/wdj51/file/src/.libs/libmagic.a /X/src/wdj51/xar/lib/.libs/ 
libxar.a -Wl,--no-whole-archive  -L/X/src/wdj51/db3 -L/X/src/wdj51/lua  
-L/X/src/wdj51/file/src -L/X/src/wdj51/file -L/X/src/wdj51/xar/lib -L/ 
X/src/wdj51/xar -L/usr/kerberos/lib -lxml2 -lkeyutils -lossp-uuid - 
lpcreposix -lm -lsqlite3 -lbeecrypt -lbz2 -lpopt -lrt -lelf -lselinux - 
lssl3 -lsmime3 -lnss3 -lnssutil3 -lplds4 -lplc4 -lnspr4 -lpthread - 
lssl -lcrypto -ldl -lz /usr/lib/libneon.so -lpcre -luuid  -Wl,-- 
version-script=./librpmmisc.vers -Wl,-soname -Wl,librpmmisc-5.0.so - 
o .libs/librpmmisc-5.0.so

The only additions are "-pie -nostartfiles".

tia

73 de Jeff

On Oct 26, 2008, at 8:36 PM, Jeff Johnson wrote:

>  RPM Package Manager, CVS Repository
>  http://rpm5.org/cvs/
>   
> ____________________________________________________________________________
>
>  Server: rpm5.org                         Name:   Jeff Johnson
>  Root:   /v/rpm/cvs                       Email:  jbj@rpm5.org
>  Module: rpm lua                          Date:   27-Oct-2008 01:36:52
>  Branch: rpm-5_1                          Handle: 2008102700365101
>
>  Modified files:           (Branch: rpm-5_1)
>    lua/shadow              copydir.c list.c strtoday.c useradd.c
>    rpm                     CHANGES
>
>  Log:
>    - jbj: WRlua: preserve forward linkage by avoiding vmefail/ 
> get_date.
>
>  Summary:
>    Revision    Changes     Path
>    1.1.2.4     +8  -6      lua/shadow/copydir.c
>    1.1.2.4     +20 -8      lua/shadow/list.c
>    1.1.2.4     +5  -2      lua/shadow/strtoday.c
>    1.1.2.5     +22 -17     lua/shadow/useradd.c
>    1.2288.2.143+1  -0      rpm/CHANGES
>   
> ____________________________________________________________________________
>
>  patch -p0 <<'@@ .'
>  Index: lua/shadow/copydir.c
>   
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
>  $ cvs diff -u -r1.1.2.3 -r1.1.2.4 copydir.c
>  --- lua/shadow/copydir.c	18 Aug 2008 19:47:16 -0000	1.1.2.3
>  +++ lua/shadow/copydir.c	27 Oct 2008 00:36:52 -0000	1.1.2.4
>  @@ -36,18 +36,18 @@
>   #include "system.h"
>   #include "shadow_config.h"
>
>  -#ident "$Id: copydir.c,v 1.1.2.3 2008/08/18 19:47:16 jbj Exp $"
>  +#ident "$Id: copydir.c,v 1.1.2.4 2008/10/27 00:36:52 jbj Exp $"
>
>  -#include <sys/stat.h>
>  -#include <sys/types.h>
>   #include <fcntl.h>
>  -#include <stdio.h>
>   #include "prototypes.h"
>   #include "defines.h"
>   #ifdef WITH_SELINUX
>   #include <selinux/selinux.h>
>   static int selinux_enabled = -1;
>   #endif
>  +
>  +#include "debug.h"
>  +
>   static const char *src_orig;
>   static const char *dst_orig;
>
>  @@ -125,7 +125,8 @@
>   	if (sb->st_nlink == 1)
>   		return 0;
>
>  -	lp = (struct link_name *) xmalloc (sizeof *lp);
>  +	lp = (struct link_name *) malloc (sizeof *lp);
>  +assert(lp != NULL);
>   	src_len = strlen (src_orig);
>   	dst_len = strlen (dst_orig);
>   	name_len = strlen (name);
>  @@ -133,7 +134,8 @@
>   	lp->ln_ino = sb->st_ino;
>   	lp->ln_count = sb->st_nlink;
>   	len = name_len - src_len + dst_len + 1;
>  -	lp->ln_name = xmalloc (len);
>  +	lp->ln_name = malloc (len);
>  +assert(lp->ln_name != NULL);
>   	snprintf (lp->ln_name, len, "%s%s", dst_orig, name + src_len);
>   	lp->ln_next = links;
>   	links = lp;
>  @@ .
>  patch -p0 <<'@@ .'
>  Index: lua/shadow/list.c
>   
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
>  $ cvs diff -u -r1.1.2.3 -r1.1.2.4 list.c
>  --- lua/shadow/list.c	18 Aug 2008 19:47:17 -0000	1.1.2.3
>  +++ lua/shadow/list.c	27 Oct 2008 00:36:52 -0000	1.1.2.4
>  @@ -39,10 +39,13 @@
>   #include "system.h"
>   #include "shadow_config.h"
>
>  -#ident "$Id: list.c,v 1.1.2.3 2008/08/18 19:47:17 jbj Exp $"
>  +#ident "$Id: list.c,v 1.1.2.4 2008/10/27 00:36:52 jbj Exp $"
>
>   #include "prototypes.h"
>   #include "defines.h"
>  +
>  +#include "debug.h"
>  +
>   /*
>    * add_list - add a member to a list of group members
>    *
>  @@ -69,7 +72,8 @@
>   	 * old entries, and the new entries as well.
>   	 */
>
>  -	tmp = (char **) xmalloc ((i + 2) * sizeof member);
>  +	tmp = (char **) malloc ((i + 2) * sizeof member);
>  +assert(tmp != NULL);
>
>   	/*
>   	 * Copy the original list to the new list, then append the
>  @@ -80,7 +84,9 @@
>   	for (i = 0; list[i] != (char *) 0; i++)
>   		tmp[i] = list[i];
>
>  -	tmp[i++] = xstrdup (member);
>  +	tmp[i] = strdup (member);
>  +assert(tmp[i] != NULL);
>  +	i++;
>   	tmp[i] = (char *) 0;
>
>   	return tmp;
>  @@ -116,7 +122,8 @@
>   	 * old entries.
>   	 */
>
>  -	tmp = (char **) xmalloc ((j + 1) * sizeof member);
>  +	tmp = (char **) malloc ((j + 1) * sizeof member);
>  +assert(tmp != NULL);
>
>   	/*
>   	 * Copy the original list except the deleted members to the
>  @@ -140,11 +147,14 @@
>
>   	for (i = 0; list[i]; i++);
>
>  -	tmp = (char **) xmalloc ((i + 1) * sizeof (char *));
>  +	tmp = (char **) malloc ((i + 1) * sizeof (char *));
>  +assert(tmp != NULL);
>
>   	i = 0;
>   	while (*list) {
>  -		tmp[i++] = xstrdup (*list);
>  +		tmp[i] = strdup (*list);
>  +assert(tmp[i] != NULL);
>  +		i++;
>   		list++;
>   	}
>
>  @@ -177,7 +187,8 @@
>   	 * Make a copy since we are going to be modifying the list
>   	 */
>
>  -	members = xstrdup (comma);
>  +	members =strdup (comma);
>  +assert(members != NULL);
>
>   	/*
>   	 * Count the number of commas in the list
>  @@ -199,7 +210,8 @@
>   	 * Allocate the array we're going to store the pointers into.
>   	 */
>
>  -	array = (char **) xmalloc (sizeof (char *) * i);
>  +	array = (char **) malloc (sizeof (char *) * i);
>  +assert(array != NULL);
>
>   	/*
>   	 * Empty list is special - 0 members, not 1 empty member.  --marekm
>  @@ .
>  patch -p0 <<'@@ .'
>  Index: lua/shadow/strtoday.c
>   
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
>  $ cvs diff -u -r1.1.2.3 -r1.1.2.4 strtoday.c
>  --- lua/shadow/strtoday.c	18 Aug 2008 19:47:17 -0000	1.1.2.3
>  +++ lua/shadow/strtoday.c	27 Oct 2008 00:36:52 -0000	1.1.2.4
>  @@ -42,13 +42,16 @@
>   #include "defines.h"
>   #include "prototypes.h"
>
>  -#ident "$Id: strtoday.c,v 1.1.2.3 2008/08/18 19:47:17 jbj Exp $"
>  +#ident "$Id: strtoday.c,v 1.1.2.4 2008/10/27 00:36:52 jbj Exp $"
>
>   #ifndef USE_GETDATE
>   #define USE_GETDATE 1
>   #endif
>  +
>  +#define get_date	shadow_get_date
>  +#include "../../rpmio/getdate.c"
>  +
>   #if USE_GETDATE
>  -extern time_t get_date (const char *, const time_t *);
>
>   /*
>    * strtoday() now uses get_date() (borrowed from GNU shellutils)
>  @@ .
>  patch -p0 <<'@@ .'
>  Index: lua/shadow/useradd.c
>   
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
>  $ cvs diff -u -r1.1.2.4 -r1.1.2.5 useradd.c
>  --- lua/shadow/useradd.c	18 Aug 2008 19:47:17 -0000	1.1.2.4
>  +++ lua/shadow/useradd.c	27 Oct 2008 00:36:52 -0000	1.1.2.5
>  @@ -36,11 +36,8 @@
>   #include "system.h"
>   #include "shadow_config.h"
>
>  -#ident "$Id: useradd.c,v 1.1.2.4 2008/08/18 19:47:17 jbj Exp $"
>  +#ident "$Id: useradd.c,v 1.1.2.5 2008/10/27 00:36:52 jbj Exp $"
>
>  -#include <ctype.h>
>  -#include <errno.h>
>  -#include <fcntl.h>
>   #include <getopt.h>
>   #include <grp.h>
>   #include <lastlog.h>
>  @@ -48,10 +45,6 @@
>   #ifdef USE_PAM
>   #include "pam_defs.h"
>   #endif				/* USE_PAM */
>  -#include <stdio.h>
>  -#include <sys/stat.h>
>  -#include <sys/types.h>
>  -#include <time.h>
>   #include <setjmp.h>
>   #include "chkname.h"
>   #include "defines.h"
>  @@ -67,6 +60,8 @@
>   #endif
>   #include "shadowio.h"
>
>  +#include "debug.h"
>  +
>   #ifndef SKEL_DIR
>   #define SKEL_DIR "/etc/skel"
>   #endif
>  @@ -357,7 +352,8 @@
>   			if (*cp != '\0' && *ep == '\0') {	/* valid number */
>   				def_group = val;
>   				if ((grp = lcl_getgrgid (def_group))) {
>  -					def_gname = xstrdup (grp->gr_name);
>  +					def_gname = strdup (grp->gr_name);
>  +assert(def_gname != NULL);
>   				} else {
>   					fprintf (stderr,
>   						 _("%s: unknown GID %s\n"),
>  @@ -365,7 +361,8 @@
>   				}
>   			} else if ((grp = lcl_getgrnam (cp))) {
>   				def_group = grp->gr_gid;
>  -				def_gname = xstrdup (cp);
>  +				def_gname = strdup (cp);
>  +assert(def_gname != NULL);
>   			} else {
>   				fprintf (stderr,
>   					 _("%s: unknown group %s\n"), Prog, cp);
>  @@ -376,14 +373,16 @@
>   		 * Default HOME filesystem
>   		 */
>   		else if (MATCH (buf, HOME)) {
>  -			def_home = xstrdup (cp);
>  +			def_home = strdup (cp);
>  +assert(def_home != NULL);
>   		}
>
>   		/*
>   		 * Default Login Shell command
>   		 */
>   		else if (MATCH (buf, SHELL)) {
>  -			def_shell = xstrdup (cp);
>  +			def_shell = strdup (cp);
>  +assert(def_shell != NULL);
>   		}
>
>   		/*
>  @@ -402,7 +401,8 @@
>   		 * Default account expiration date
>   		 */
>   		else if (MATCH (buf, EXPIRE)) {
>  -			def_expire = xstrdup (cp);
>  +			def_expire = strdup (cp);
>  +assert(def_expire != NULL);
>   		}
>
>   		/*
>  @@ -412,7 +412,8 @@
>   			if (*cp == '\0')
>   				cp = SKEL_DIR;	/* XXX warning: const */
>
>  -			def_template = xstrdup (cp);
>  +			def_template = strdup (cp);
>  +assert(def_template != NULL);
>   		}
>
>   		/*
>  @@ -422,7 +423,8 @@
>   			if (*cp == '\0')
>   				cp = CREATE_MAIL_SPOOL;	/* XXX warning: const */
>
>  -			def_create_mail_spool = xstrdup (cp);
>  +			def_create_mail_spool = strdup (cp);
>  +assert(def_create_mail_spool != NULL);
>   		}
>   	}
>   }
>  @@ -665,7 +667,9 @@
>   		/*
>   		 * Add the group name to the user's list of groups.
>   		 */
>  -		user_groups[ngroups++] = xstrdup (grp->gr_name);
>  +		user_groups[ngroups] = strdup (grp->gr_name);
>  +assert(user_groups[ngroups] != NULL);
>  +		ngroups++;
>   	} while (list);
>
>   	user_groups[ngroups] = (char *) 0;
>  @@ -1350,8 +1354,9 @@
>   		if (!dflg) {
>   			char *uh;
>
>  -			uh = xmalloc (strlen (def_home) +
>  +			uh = malloc (strlen (def_home) +
>   				      strlen (user_name) + 2);
>  +assert(uh != NULL);
>   			sprintf (uh, "%s/%s", def_home, user_name);
>   			user_home = uh;
>   		}
>  @@ .
>  patch -p0 <<'@@ .'
>  Index: rpm/CHANGES
>   
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
>  $ cvs diff -u -r1.2288.2.142 -r1.2288.2.143 CHANGES
>  --- rpm/CHANGES	26 Oct 2008 18:42:51 -0000	1.2288.2.142
>  +++ rpm/CHANGES	27 Oct 2008 00:36:51 -0000	1.2288.2.143
>  @@ -1,4 +1,5 @@
>   5.1.6 -> 5.1.7:
>  +    - jbj: WRlua: preserve forward linkage by avoiding vmefail/ 
> get_date.
>       - jbj: add a relation to to force install-before-erase.
>       - jbj: display dependency loops as an error for now.
>
>  @@ .
> ______________________________________________________________________
> RPM Package Manager                                    http://rpm5.org
> CVS Sources Repository                                rpm-cvs@rpm5.org
Received on Mon Oct 27 01:46:20 2008
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.