[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
"home" bug fixed (update)
From: |
Robert Shaw |
Subject: |
"home" bug fixed (update) |
Date: |
Wed, 07 Feb 2001 21:39:13 -0700 |
Mark,
Here's an updated version of the "home" bug patch. This makes the group
check on the file copied to a home directory smarter. It first checks
that it can find a group defined before setting it (just like it does
for the user id). Plus, the debug message prints the name instead of the
id now.
Please add the fixes to the next release.
Thanks!!
-Robert
--- cfengine-1.6.2.orig/src/image.c Fri Jan 5 14:27:53 2001
+++ cfengine-1.6.2/src/image.c Wed Feb 7 21:29:57 2001
@@ -219,14 +219,16 @@
struct Image *ip;
-{ CFDIR *dirh, *dirh2;
- struct cfdirent *dirp, *dirp2;
+{ DIR *dirh, *dirh2;
+ struct dirent *dirp, *dirp2;
char *ReadLastNode(), username[maxvarsize];
char homedir[bufsize],dest[bufsize];
struct passwd *pw;
+ struct group *gr;
struct stat statbuf;
struct Item *itp;
int request_uid = ip->uid->uid; /* save if -1 */
+ int request_gid = ip->gid->gid; /* save if -1 */
if (!MountPathDefined())
{
@@ -234,7 +236,7 @@
return;
}
-if (cfstat(ip->path,&statbuf,ip))
+if (cfstat(ip->path,&statbuf,ip) == -1)
{
sprintf(OUTPUT,"Master file %s doesn't exist for copying\n",ip->path);
CfLog(cferror,OUTPUT,"");
@@ -248,16 +250,16 @@
continue;
}
- if ((dirh = cfopendir(itp->name,ip)) == NULL)
+ if ((dirh = opendir(itp->name)) == NULL)
{
sprintf(OUTPUT,"Can't open directory %s\n",itp->name);
- CfLog(cferror,OUTPUT,"cfopendir");
+ CfLog(cferror,OUTPUT,"opendir");
return;
}
- for (dirp = cfreaddir(dirh,ip); dirp != NULL; dirp = cfreaddir(dirh,ip))
+ for (dirp = readdir(dirh); dirp != NULL; dirp = readdir(dirh))
{
- if (!SensibleFile(dirp->d_name,itp->name,ip))
+ if (!SensibleFile(dirp->d_name,itp->name,NULL))
{
continue;
}
@@ -271,16 +273,16 @@
continue;
}
- if ((dirh2 = cfopendir(homedir,ip)) == NULL)
+ if ((dirh2 = opendir(homedir)) == NULL)
{
sprintf(OUTPUT,"Can't open directory %s\n",homedir);
- CfLog(cferror,OUTPUT,"cfopendir");
+ CfLog(cferror,OUTPUT,"opendir");
return;
}
- for (dirp2 = cfreaddir(dirh2,ip); dirp2 != NULL; dirp2 =
cfreaddir(dirh2,ip))
+ for (dirp2 = readdir(dirh2); dirp2 != NULL; dirp2 = readdir(dirh2))
{
- if (!SensibleFile(dirp2->d_name,homedir,ip))
+ if (!SensibleFile(dirp2->d_name,homedir,NULL))
{
continue;
}
@@ -314,17 +316,38 @@
}
else
{
- Debug2("(Setting user id to %s)\n",username);
+ Debug2("(Setting user id to %s)\n",pw->pw_name);
}
ip->uid->uid = pw->pw_uid;
}
+ if (request_gid == -1)
+ {
+ if ((pw = getpwnam(username)) == NULL)
+ {
+ Debug2("cfengine: directory corresponds to no user %s -
ignoring\n",username);
+ continue;
+ }
+
+ if ((gr = getgrgid(pw->pw_gid)) == NULL)
+ {
+ Debug2("cfengine: no group defined for group id %d -
ignoring\n",pw->pw_gid);
+ continue;
+ }
+ else
+ {
+ Debug2("(Setting group id to %s)\n",gr->gr_name);
+ }
+
+ ip->gid->gid = gr->gr_gid;
+ }
+
CheckImage(ip->path,dest,ip);
}
- cfclosedir(dirh2);
+ closedir(dirh2);
}
- cfclosedir(dirh);
+ closedir(dirh);
}
}
- "home" bug fixed, Robert Shaw, 2001/02/07
- "home" bug fixed (update),
Robert Shaw <=