11.21.05

Second attempt at nALFS + package users

Posted in lfs at 20051121182500 by tmayad

Categories:

Last night I have run another build and found a few problems.

11.20.05

First attempt at nALFS + package users

Posted in lfs at 20051120155900 by tmayad

Categories:

I tried to modify the LFS-6.1-1 ALFS profile for implimenting the changes. I used 6.1 live cd and there are a few digest mismatches. Apparently there was a server hickup and things changed. I guess it’s okay to ignore them. The rest of the errors and temporary work arounds are here.

patched nALFS to use /etc/passwd from $LFS

Posted in lfs at 20051120154500 by tmayad

Categories:

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;

11.17.05

Psst…

Posted in Uncategorized at 20051117192503 by tmayad

Achelon!?

What does it mean? Nothing. It just popped into my head.

Now..now.. How many new names and titles can one think of? Atleast my “creativity” levels are this good.anyways, this is just a site I want to use with another of my friend.

patched nALFS to use uid:gid style user info

Posted in lfs at 20051117070300 by tmayad

Categories:

As I got no replies for my mail to alfs mailing list, I have finally decided to get my hands dirtier (They are already dirty). I have made a patch for nALFS that seems to do the job of using <user>uid:gid</user>. the usual at your own risk blah blah… disclaimer.

The format <user>uid:gid</user> has to be strictly followed and it won’t check for the format, neither does it have any defaults in case you omit anything. I don’t know if I have broken the original functionality. I had to bypass the user not found check and I didn’t care to adopt it, instead I removed it. So I suggest either you look into it and modify it further or wait till my exams are over and I’ll be more free to work them out.

There is one more catch, there are two files with same function which are exact replicas. But I changed only one that was being used when I traced it in gdb. Be warned, its only a couple of days since I started using gdb. Thanks to Kousik and Sunny.

nALFS-1.2.5-user-UID.patch


diff -Naur nALFS-1.2.5/src/handlers/stage.c nALFS-1.2.5-#/src/handlers/stage.c
--- nALFS-1.2.5/src/handlers/stage.c 2004-07-04 11:21:11.000000000 +0530
+++ nALFS-1.2.5-#/src/handlers/stage.c 2005-11-17 06:18:00.000000000 +0530
@@ -103,8 +103,9 @@
 static INLINE int change_to_user(const char *user)
 {
  struct passwd *pw;
-
-
+ uid_t uid;
+ gid_t gid;
+
  setpwent();

  /* getpwnam() is failing in chroot() */
@@ -118,20 +119,28 @@

  if (pw == NULL) {
   Nprint_h_err("User %s doesn't exist.", user);
-  return -1;
+  // return -1;
+  //check for UID
+  uid = atoi(strtok(user,":"));
+  gid = atoi(strtok(NULL,""));
+ }
+ else
+ {
+  uid = pw->pw_uid;
+  gid = pw->pw_gid;
  }

- if (set_supplementary_groups(user, pw->pw_gid)) {
+ if (set_supplementary_groups(user, gid)) {
   return -1;
  }

- if (setgid(pw->pw_gid)) {
+ if (setgid(gid)) {
   Nprint_h_err("Unable to set group ID: %s",
    strerror(errno));
   return -1;
  }

- if (setuid(pw->pw_uid)) {
+ if (setuid(uid)) {
   Nprint_h_err("Unable to set user ID: %s",
    strerror(errno));
   return -1;

11.09.05

package users and nALFS: define package id in users tag

Posted in lfs at 20051109003300 by tmayad

Categories:

The other option Iwas left with is to use use numeric uid in <users></users>.
But can it take the syntax <users>uid:gid</users> because without gid, it is going to be a mess unless taken care of. or is it going to default to the uid value for gid too? I have to experiment and find out. unless some one can help me here.

Another thing I can do is (in case it won’t take the gid) set the gid while cleaning up with something like find / -uid $UID -exec chgrp $GID {} and take extra care to set gid before making any suids.

11.08.05

Bug 1058 – changing user breaks when chrooted in script

Posted in lfs at 20051108221700 by tmayad

Bug 1058 – changing user breaks when chrooted in script

I tried to make matching entries in /etc/passwd and /etc/groups on the host and still getting the user not found error.

Here are the contents I appended to the host contents.

/etc/passwd

linux-libc-headers:x:10000:10000:2.6.11.2:/usr/src/libc-headers:/bin/bash
man-pages:x:10001:10001:2.01:/usr/src/man-pages:/bin/bash
glibc:x:10002:10002:2.3.4:/usr/src/glibc:/bin/bash
binutils:x:10003:10003:2.15.94.0.2.2:/usr/src/binutils:/bin/bash
gcc:x:10004:10004:3.4.3:/usr/src/gcc:/bin/bash
coreutils:x:10005:10005:5.2.1:/usr/src/coreutils:/bin/bash
zlib:x:10006:10006:1.2.2:/usr/src/zlib:/bin/bash
mktemp:x:10007:10007:1.5:/usr/src/mktemp:/bin/bash
iana-etc:x:10008:10008:1.04:/usr/src/iana-etc:/bin/bash
findutils:x:10009:10009:4.2.23:/usr/src/findutils:/bin/bash
gawk:x:10010:10010:3.1.4:/usr/src/gawk:/bin/bash
ncurses:x:10011:10011:5.4:/usr/src/ncurses:/bin/bash
readline:x:10012:10012:5.0:/usr/src/readline:/bin/bash
vim:x:10013:10013:6.3:/usr/src/vim:/bin/bash
m4:x:10014:10014:1.4.3:/usr/src/m4:/bin/bash
bison:x:10015:10015:2.0:/usr/src/bison:/bin/bash
less:x:10016:10016:382:/usr/src/less:/bin/bash
groff:x:10017:10017:1.19.1:/usr/src/groff:/bin/bash
sed:x:10018:10018:4.1.4:/usr/src/sed:/bin/bash
flex:x:10019:10019:2.5.31:/usr/src/flex:/bin/bash
gettext:x:10020:10020:0.14.3:/usr/src/gettext:/bin/bash
inetutils:x:10021:10021:1.4.2:/usr/src/inetutils:/bin/bash
iproute2:x:10022:10022:2.6.11:/usr/src/iproute2:/bin/bash
perl:x:10023:10023:5.8.6:/usr/src/perl:/bin/bash
texinfo:x:10024:10024:4.8:/usr/src/texinfo:/bin/bash
autoconf:x:10025:10025:2.59:/usr/src/autoconf:/bin/bash
automake:x:10026:10026:1.9.5:/usr/src/automake:/bin/bash
bash:x:10027:10027:3.0:/usr/src/bash:/bin/bash
file:x:10028:10028:4.13:/usr/src/file:/bin/bash
libtool:x:10029:10029:1.5.14:/usr/src/libtool:/bin/bash
bzip2:x:10030:10030:1.0.3:/usr/src/bzip2:/bin/bash
diffutils:x:10031:10031:2.8.1:/usr/src/diffutils:/bin/bash
kbd:x:10032:10032:1.12:/usr/src/kbd:/bin/bash
e2fsprogs:x:10033:10033:1.37:/usr/src/e2fsprogs:/bin/bash
grep:x:10034:10034:2.5.1a:/usr/src/grep:/bin/bash
grub:x:10035:10035:0.96:/usr/src/grub:/bin/bash
gzip:x:10036:10036:1.3.5:/usr/src/gzip:/bin/bash
hotplug:x:10037:10037:2004_09_23:/usr/src/hotplug:/bin/bash
man:x:10038:10038:1.5p:/usr/src/man:/bin/bash
make:x:10039:10039:3.80:/usr/src/make:/bin/bash
module-init-tools:x:10040:10040:3.1:/usr/src/module-init-tools:/bin/bash
patch:x:10041:10041:2.5.4:/usr/src/patch:/bin/bash
procps:x:10042:10042:3.2.5:/usr/src/procps:/bin/bash
psmisc:x:10043:10043:21.6:/usr/src/psmisc:/bin/bash
shadow:x:10044:10044:4.0.9:/usr/src/shadow:/bin/bash
sysklogd:x:10045:10045:1.4.1:/usr/src/sysklogd:/bin/bash
sysvinit:x:10046:10046:2.86:/usr/src/sysvinit:/bin/bash
tar:x:10047:10047:1.15.1:/usr/src/tar:/bin/bash
udev:x:10048:10048:056:/usr/src/udev:/bin/bash
util-linux:x:10049:10049:2.12q:/usr/src/util-linux:/bin/bash

/etc/group

linux-libc-headers:x:10000:
man-pages:x:10001:
glibc:x:10002:
binutils:x:10003:
gcc:x:10004:
coreutils:x:10005:
zlib:x:10006:
mktemp:x:10007:
iana-etc:x:10008:
findutils:x:10009:
gawk:x:10010:
ncurses:x:10011:
readline:x:10012:
vim:x:10013:
m4:x:10014:
bison:x:10015:
less:x:10016:
groff:x:10017:
sed:x:10018:
flex:x:10019:
gettext:x:10020:
inetutils:x:10021:
iproute2:x:10022:
perl:x:10023:
texinfo:x:10024:
autoconf:x:10025:
automake:x:10026:
bash:x:10027:
file:x:10028:
libtool:x:10029:
bzip2:x:10030:
diffutils:x:10031:
kbd:x:10032:
e2fsprogs:x:10033:
grep:x:10034:
grub:x:10035:
gzip:x:10036:
hotplug:x:10037:
man:x:10038:
make:x:10039:
module-init-tools:x:10040:
patch:x:10041:
procps:x:10042:
psmisc:x:10043:
shadow:x:10044:
sysklogd:x:10045:
sysvinit:x:10046:
tar:x:10047:
udev:x:10048:
util-linux:x:10049: