#561988 cpio complains about invalid user although the user is correct

Package:
cpio
Source:
cpio
Description:
GNU cpio -- a program to manage archives of files
Submitter:
Christian Brabandt
Date:
2010-04-13 23:30:03 UTC
Severity:
important
#561988#5
Date:
2009-12-21 19:44:32 UTC
From:
To:
There seems to be a bug somewhere:
chrisbra@256bit:~$ find . -depth |cpio --pass-through
--preserve-modification-time --make-directories --unconditional -R 
chrisbra ../target/ cpio: chrisbra: invalid user

chricbra@256bit.org:~$ getent passwd |grep chrisbra
chrisbra:x:1004:100::/home/chrisbra:/bin/bash

Obviously, the user exists.

#561988#10
Date:
2009-12-22 23:58:39 UTC
From:
To:
That does look broken, but I can't reproduce it.

Does `getent passwd chisbra` show the same line?

#561988#15
Date:
2009-12-23 14:47:10 UTC
From:
To:
Hallo Clint!

Clint Adams schrieb am Dienstag, den 22. Dezember 2009:

I have to add, this only affects cpio-2.9 from lenny. My C-Skills are a
little bit rusty, but the following patch seems to work for me:

chrisbra t41:~/source/cpio/cpio-2.9/src [1081:1]% diff -Nu userspec.c{.old,}
--- userspec.c.old      2009-12-23 15:40:09.000000000 +0100
+++ userspec.c  2009-12-23 15:40:21.000000000 +0100
@@ -108,7 +108,7 @@
   char *spec;                  /* A copy we can write on.  */
   struct passwd *pwd;
   struct group *grp;
-  char *g, *u, *separator;
+  unsigned char *g, *u, *separator;
   char *groupname;

   error_msg = NULL;

Yes:
chrisbra@256bit:~/temp/source$ getent passwd chrisbra
chrisbra:x:1004:100::/home/chrisbra:/bin/bash


regards,
Christian

#561988#20
Date:
2009-12-24 19:39:37 UTC
From:
To:
Oh, well, I'm afraid there's not much I can do for lenny but create an
unofficial backport of 2.10.  Would that help?

I'm confused; what is expecting those characters to be unsigned?

#561988#25
Date:
2009-12-25 15:44:03 UTC
From:
To:
Hallo Clint!

Clint Adams schrieb am Donnerstag, den 24. Dezember 2009:

Yes, very much.

A far lines later, you'll find that piece of code:
f (!isnumber_p (u))
    error_msg = _("invalid user");

and isnumber_p fails, because u was negative in my case.


regards,
Christian

#561988#30
Date:
2009-12-26 05:08:32 UTC
From:
To:
Maybe I'm dense.  Why would isnumber_p() fail on a signed char string?
#561988#35
Date:
2009-12-26 13:15:25 UTC
From:
To:
Hallo Clint!

Clint Adams schrieb am Samstag, den 26. Dezember 2009:

Because it is just a wrapper that runs isdigit (3) on each char in a
loop. And from the manpage isalpha(3) and don't see, that isdigit checks
for negative numbers.

Well, as I said, my C-Skills are pretty rusty. May be I misunderstood
something.

regards,
Christian

#561988#40
Date:
2009-12-27 15:22:55 UTC
From:
To:
Hallo Clint!

Clint Adams schrieb am Samstag, den 26. Dezember 2009:

Sorry, I must have been confused. My patch actually does not change
anything. Something must have messed up my test.

regards,
Christian

#561988#45
Date:
2010-04-13 20:28:05 UTC
From:
To:
Additional data:

Ran into this bug after upgrading an ia64 box Etch->Lenny. Haven't
root-caused the bug, but have found a workaround.

In the cpio source file lib/system.c is the following code segment:

#ifndef HAVE_GETPWNAM
struct passwd *
getpwnam (const char *name __attribute__ ((unused)))
{
  errno = ENOSYS;
  return NULL;
}
#endif

#ifndef HAVE_GETGRGID
struct group *
getgrgid (gid_t gid __attribute__ ((unused)))
{
  errno = ENOSYS;
  return NULL;
}
#endif

#ifndef HAVE_GETGRNAM
struct group *
getgrnam (const char *name __attribute__ ((unused)))
{
  errno = ENOSYS;
  return NULL;
}
#endif

It appears that HAVE_GETPWNAM, HAVE_GETGRGID, and HAVE_GETGRNAM are not
being defined even though the system does support the getpwnam(),
getgrgid(), and getpwnam() calls. Autoconf problem? This causes cpio to
be compiled with the lib/system.c versions of the aforementioned
functions instead of linking to the system library versions. Commenting
out the above code segment and recompiling fixes the problem.

Regards,

Bill Skinner

#561988#50
Date:
2010-04-13 23:17:14 UTC
From:
To:
That's interesting.  Unfortunately I don't have the build logs from that
far back to check the configure output.