Categories: LFS
The earlier patch for uid:gid
failed because You can't use it to set additional groups which is required because package users use sticky bit of install dirs owned by install
group.
So once more I found myself looking at nALFS code. This time I was looking at change group function in stage.c and discovered that it had been modified earlier for use in chroot
environment. I knew it when I saw because I was hoping to use the fget....
functions too. Hmm, looks like the team has forgot to change the change_to_user
function. I did it and here is the patch. It's working just fine.
nALFS-1.2.5-change_to_user.patch
static INLINE int change_to_user(const char *user)
{
struct passwd *pw;
+ FILE *fp;
-
- setpwent();
-
- /* getpwnam() is failing in chroot() */
- while ((pw = getpwent())) {
- if (strcmp(pw->pw_name, user) == 0) {
- break;
+ if ((fp = fopen("/etc/passwd", "r"))) { //setpwent();
+ /* getpwnam() is failing in chroot() */
+ while ((pw = fgetpwent(fp))) {
+ if (strcmp(pw->pw_name, user) == 0) {
+ break;
+ }
}
- }
- endpwent();
+ fclose(fp); //endpwent();
+ } else {
+ Nprint_h_warn("Unable to open /etc/passwd: %s",
+ strerror(errno));
+ }
if (pw == NULL) {
Nprint_h_err("User %s doesn't exist.", user);
return -1;
No comments:
Post a Comment