Download Firefox: WindowsMac OS X
logo       
Google Custom Search
    AddThis Social Bookmark Button

Re: Force user for file in src.rpm: msg#00018

Subject: Re: Force user for file in src.rpm
Le Saturday 4 June 2005 02:36, Jeff Johnson a écrit :
> On Jun 3, 2005, at 7:10 PM, Olivier Thauvin wrote:
> > RPM is allways complaining about non existing user/group when
> > installing
> > src.rpm. Those information are very usefull. To avoid this a quick
> > solution
> > is to set root/root as owner (uid=gid=0) of all files in src.rpm.
>
> (after looking at source line no's ;0(
>
> This is the right place, but you can avoid some problems with getpwnam
> (3) lookup if the macros are either
> constant strings (like "root") or string valued (i.e. "%_sources_user
> root" in default macro config) rather
> than logical variables that change program flow.
>
> Something like
>      u = rpmExpand("%{?_sources_user}", NULL)
>      flp->uname = (u && *u ? u :  getUname(flp->fl_uid))
> similarly for flp->gname;
>
> (Note: there's a memory leak for u that needs fixing).
>
> Otherwise looks okay.

Resending the patch:

- macro expansion done only one time for the whole process
- _free source + group at the end of the function

Index: build/files.c
===================================================================
RCS file: /cvs/devel/rpm/build/files.c,v
retrieving revision 1.242
diff -u -p -r1.242 files.c
--- build/files.c       25 Mar 2005 17:30:34 -0000      1.242
+++ build/files.c       4 Jun 2005 13:05:45 -0000
@@ -2265,6 +2265,7 @@ int processSourceFiles(Spec spec)
     struct FileList_s fl;
     char *s, **files, **fp;
     Package pkg;
+    char * sourceUser, *sourceGroup;

     sourceFiles = newStringBuf();

@@ -2326,6 +2327,10 @@ int processSourceFiles(Spec spec)
     s = getStringBuf(sourceFiles);
     files = splitString(s, strlen(s), '\n');

+    /* Do we force owner for source */
+    sourceUser = rpmExpand("%{?_sources_user}", NULL);
+    sourceGroup = rpmExpand("%{?_sources_group}", NULL);
+
     /* The first source file is the spec file */
     x = 0;
     for (fp = files; *fp != NULL; fp++) {
@@ -2364,8 +2369,8 @@ int processSourceFiles(Spec spec)
            fl.processingFailed = 1;
        }

-       flp->uname = getUname(flp->fl_uid);
-       flp->gname = getGname(flp->fl_gid);
+       flp->uname = (sourceUser && *sourceUser ? sourceUser : 
getUname(flp->fl_uid));
+       flp->gname = (sourceGroup && *sourceGroup ? sourceGroup : 
getGname(flp->fl_gid));
        flp->langs = xstrdup("");

        fl.totalFileSize += flp->fl_size;
@@ -2389,6 +2394,8 @@ int processSourceFiles(Spec spec)

     sourceFiles = freeStringBuf(sourceFiles);
     fl.fileList = freeFileList(fl.fileList, fl.fileListRecsUsed);
+    _free(sourceUser);
+    _free(sourceGroup);
     return fl.processingFailed;
 }

Attachment: pgppSl9wfOAUY.pgp
Description: PGP signature

_______________________________________________
Rpm-devel mailing list
Rpm-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.dulug.duke.edu/mailman/listinfo/rpm-devel
<Prev in Thread] Current Thread [Next in Thread>