[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] - OS X support
From: |
David Botsch |
Subject: |
Re: [PATCH] - OS X support |
Date: |
Tue, 11 Nov 2003 13:12:49 -0500 |
User-agent: |
Pan/0.11.2 (Unix) |
Here's the updated patch. Let me know.
Later!
-Dave B
----------------PATCH FOLLOWS---------------------
diff -r -U5 cfengine-2.1.0p1/src/cf.defs.h cfengine-2.1.0-new/src/cf.defs.h
--- cfengine-2.1.0p1/src/cf.defs.h Wed Oct 15 07:44:46 2003
+++ cfengine-2.1.0-new/src/cf.defs.h Mon Nov 10 12:37:14 2003
@@ -147,18 +147,23 @@
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_MALLOC_H
+#ifdef DARWIN
+#include <sys/malloc.h>
+#include <sys/paths.h>
+#else
#ifndef OPENBSD
#ifdef __FreeBSD__
#include <stdlib.h>
#else
#include <malloc.h>
#endif
#endif
#endif
+#endif
#include <fcntl.h>
#ifdef HAVE_VFS_H
# include <sys/vfs.h>
@@ -661,10 +666,11 @@
/*******************************************************************/
enum commattr /* See COMMATTRIBUTES[] in globals.c for matching entry */
{
+ cffindertype,
cfrecurse,
cfmode,
cfowner,
cfgroup,
cfage,
@@ -1395,10 +1401,11 @@
/*******************************************************************/
struct Image
{
+ char *cf_findertype; /* Type info for finder */
char done;
char *scope;
char *path;
char *destination;
char *server;
diff -r -U5 cfengine-2.1.0p1/src/cf.extern.h cfengine-2.1.0-new/src/cf.extern.h
--- cfengine-2.1.0p1/src/cf.extern.h Wed Oct 15 07:44:21 2003
+++ cfengine-2.1.0-new/src/cf.extern.h Mon Nov 10 12:38:52 2003
@@ -125,10 +125,11 @@
extern int LINENUMBER;
extern mode_t DEFAULTMODE;
extern mode_t DEFAULTSYSTEMMODE;
extern int HAVEUID;
+extern char *FINDERTYPE;
extern char *VUIDNAME;
extern char *VGIDNAME;
extern char CFSERVER[];
extern char *PROTOCOL[];
extern char VIPADDRESS[];
diff -r -U5 cfengine-2.1.0p1/src/do.c cfengine-2.1.0-new/src/do.c
--- cfengine-2.1.0p1/src/do.c Wed Oct 22 04:28:57 2003
+++ cfengine-2.1.0-new/src/do.c Mon Nov 10 12:41:00 2003
@@ -205,10 +205,11 @@
return;
}
switch (VSYSTEMHARDCLASS)
{
+ case darwin:
case sun4:
case sun3:
case ultrx:
case irix:
case irix4:
diff -r -U5 cfengine-2.1.0p1/src/filedir.c cfengine-2.1.0-new/src/filedir.c
--- cfengine-2.1.0p1/src/filedir.c Mon Aug 25 09:01:56 2003
+++ cfengine-2.1.0-new/src/filedir.c Tue Nov 11 12:49:13 2003
@@ -25,10 +25,13 @@
#include "cf.defs.h"
#include "cf.extern.h"
+#ifdef DARWIN
+#include <sys/attr.h>
+#endif
/*********************************************************************/
int IsHomeDir(name)
@@ -161,11 +164,11 @@
if ((dirh = opendir(".")) == NULL)
{
if (lstat(name,&statbuf) != -1)
{
-
CheckExistingFile(name,plus,minus,action,uidlist,gidlist,&statbuf,ptr,ptr->acl_aliases);
+
CheckExistingFile("*",name,plus,minus,action,uidlist,gidlist,&statbuf,ptr,ptr->acl_aliases);
}
return true;
}
for (dirp = readdir(dirh); dirp != NULL; dirp = readdir(dirh))
@@ -229,11 +232,11 @@
}
if (S_ISLNK(statbuf.st_mode)) /* should we ignore links? */
{
-
CheckExistingFile(pcwd,plus,minus,action,uidlist,gidlist,&statbuf,ptr,ptr->acl_aliases);
+
CheckExistingFile("*",pcwd,plus,minus,action,uidlist,gidlist,&statbuf,ptr,ptr->acl_aliases);
continue;
}
if (S_ISDIR(statbuf.st_mode))
{
@@ -243,44 +246,45 @@
}
else
{
if ((ptr->recurse > 1) || (ptr->recurse == INFINITERECURSE))
{
-
CheckExistingFile(pcwd,plus,minus,action,uidlist,gidlist,&statbuf,ptr,ptr->acl_aliases);
+
CheckExistingFile("*",pcwd,plus,minus,action,uidlist,gidlist,&statbuf,ptr,ptr->acl_aliases);
goback =
RecursiveCheck(pcwd,plus,minus,action,uidlist,gidlist,recurse-1,rlevel+1,ptr,&statbuf);
DirPop(goback,name,sb);
}
else
{
-
CheckExistingFile(pcwd,plus,minus,action,uidlist,gidlist,&statbuf,ptr,ptr->acl_aliases);
+
CheckExistingFile("*",pcwd,plus,minus,action,uidlist,gidlist,&statbuf,ptr,ptr->acl_aliases);
}
}
}
else
{
-
CheckExistingFile(pcwd,plus,minus,action,uidlist,gidlist,&statbuf,ptr,ptr->acl_aliases);
+
CheckExistingFile("*",pcwd,plus,minus,action,uidlist,gidlist,&statbuf,ptr,ptr->acl_aliases);
}
}
closedir(dirh);
return true;
}
/*********************************************************************/
-void
CheckExistingFile(file,plus,minus,action,uidlist,gidlist,dstat,ptr,acl_aliases)
+void
CheckExistingFile(cf_findertype,file,plus,minus,action,uidlist,gidlist,dstat,ptr,acl_aliases)
+char *cf_findertype;
char *file;
mode_t plus,minus;
struct UidList *uidlist;
struct GidList *gidlist;
enum fileactions action;
struct stat *dstat;
struct File *ptr;
struct Item *acl_aliases;
-
+
{ mode_t newperm = dstat->st_mode, maskvalue;
int amroot = true, fixmode = true, docompress=false;
unsigned char digest[EVP_MAX_MD_SIZE+1];
#if defined HAVE_CHFLAGS
@@ -467,10 +471,18 @@
default: break;
}
}
}
+#ifdef DARWIN
+if (CheckFinderType(file, action, cf_findertype, dstat)) {
+ if (ptr != NULL) {
+ AddMultipleClasses(ptr->defines);
+ }
+}
+#endif
+
if (CheckOwner(file,action,uidlist,gidlist,dstat))
{
if (ptr != NULL)
{
AddMultipleClasses(ptr->defines);
@@ -821,23 +833,24 @@
umask(maskvalue);
Debug("CheckExistingFile(Done)\n");
}
/*********************************************************************/
+void CheckCopiedFile(cf_findertype,
file,plus,minus,action,uidlist,gidlist,dstat,sstat,ptr,acl_aliases)
-void
CheckCopiedFile(file,plus,minus,action,uidlist,gidlist,dstat,sstat,ptr,acl_aliases)
-
+char *cf_findertype;
char *file;
mode_t plus,minus;
struct UidList *uidlist;
struct GidList *gidlist;
enum fileactions action;
struct stat *dstat;
struct stat *sstat;
struct File *ptr;
struct Item *acl_aliases;
+
{ mode_t newplus,newminus;
/* plus/minus must be relative to source file, not to
perms of newly created file! */
@@ -845,18 +858,137 @@
if ((plus == 0) && (minus == 0))
{
newplus = sstat->st_mode & 07777 | plus;
newminus = ~(sstat->st_mode & 07777 & ~minus) & 07777;
-
CheckExistingFile(file,newplus,newminus,fixall,uidlist,gidlist,dstat,NULL,acl_aliases);
+
+
CheckExistingFile(cf_findertype,file,newplus,newminus,fixall,uidlist,gidlist,dstat,NULL,acl_aliases);
}
else
{
-
CheckExistingFile(file,plus,minus,fixall,uidlist,gidlist,dstat,NULL,acl_aliases);
+
+
CheckExistingFile(cf_findertype,file,plus,minus,fixall,uidlist,gidlist,dstat,NULL,acl_aliases);
}
}
+#ifdef DARWIN
+/*********************************************************************/
+int CheckFinderType(char * file,enum fileactions action,char * cf_findertype,
struct stat * statbuf) {
+
+ /* Code modeled after hfstar's extract.c */
+ typedef struct t_fndrinfo {
+ long fdType;
+ long fdCreator;
+ short fdFlags;
+ short fdLocationV;
+ short fdLocationH;
+ short fdFldr;
+ short fdIconID;
+ short fdUnused[3];
+ char fdScript;
+ char fdXFlags;
+ short fdComment;
+ long fdPutAway;
+ } FInfo;
+
+ struct attrlist attrs;
+ struct {
+ long ssize;
+ struct timespec created;
+ struct timespec modified;
+ struct timespec changed;
+ struct timespec backup;
+ FInfo fi;
+ } fndrInfo;
+
+ int retval;
+
+ Debug("CheckFinderType of %s for %s\n", file, cf_findertype);
+
+ if (strncmp(cf_findertype, "*", bufsize) == 0 || strncmp(cf_findertype,
"", bufsize) == 0) { /* No checking - no action */
+ Debug("CheckFinderType not needed\n");
+ return 0;
+ }
+
+ attrs.bitmapcount = ATTR_BIT_MAP_COUNT;
+ attrs.reserved = 0;
+ attrs.commonattr = ATTR_CMN_CRTIME | ATTR_CMN_MODTIME | ATTR_CMN_CHGTIME |
ATTR_CMN_BKUPTIME | ATTR_CMN_FNDRINFO;
+ attrs.volattr = 0;
+ attrs.dirattr = 0;
+ attrs.fileattr = 0;
+ attrs.forkattr = 0;
+
+ memset(&fndrInfo, 0, sizeof(fndrInfo));
+
+ getattrlist(file, &attrs, &fndrInfo, sizeof(fndrInfo),0);
+
+ if (fndrInfo.fi.fdType != *(long *)cf_findertype) { /* Need to update
Finder Type field */
+ fndrInfo.fi.fdType = *(long *)cf_findertype;
+
+ /* Determine action to take */
+
+ if (S_ISLNK(statbuf->st_mode) || S_ISDIR(statbuf->st_mode)) {
+ printf("CheckFinderType: Wrong file type for %s -- skipping\n",
file);
+ return 0;
+ }
+
+ if (S_ISREG(statbuf->st_mode) && action == fixdirs) {
+ printf("CheckFinderType: Wrong file type for %s -- skipping\n",
file);
+ return 0;
+ }
+
+ switch (action)
+ {
+
+ /* Fix it */
+ case fixplain:
+ case fixdirs:
+ case fixall:
+ case touch:
+
+
+ if (DONTDO) { /* well, unless we shouldn't fix it */
+ printf("CheckFinderType: Dry run. No action taken.\n");
+ return 0;
+ }
+
+ /* setattrlist does not take back in the long ssize */
+ retval = setattrlist(file, &attrs, &fndrInfo.created,
4*sizeof(struct timespec) + sizeof(FInfo), 0);
+
+ Debug("CheckFinderType setattrlist returned %d\n", retval);
+
+ if (retval >= 0) {
+ printf("Setting Finder Type code of %s to %s\n", file,
cf_findertype);
+ }
+ else {
+ printf("Setting Finder Type code of %s to %s failed!!\n",
file, cf_findertype);
+ }
+
+ return retval;
+
+ /* Just warn */
+ case linkchildren:
+ case warnall:
+ case warndirs:
+ case warnplain:
+ printf("Warning: FinderType does not match -- not fixing.\n");
+ return 0;
+
+ default:
+ printf("Should never get here. Aroo?\n");
+ return 0;
+ }
+ }
+
+ else {
+ Debug("CheckFinderType matched\n");
+ return 0;
+ }
+}
+
+
+#endif
/*********************************************************************/
int CheckOwner(file,action,uidlist,gidlist,statbuf)
char *file;
diff -r -U5 cfengine-2.1.0p1/src/filenames.c cfengine-2.1.0-new/src/filenames.c
--- cfengine-2.1.0p1/src/filenames.c Sat Sep 20 17:24:59 2003
+++ cfengine-2.1.0-new/src/filenames.c Mon Nov 3 15:20:23 2003
@@ -328,19 +328,34 @@
struct stat statbuf;
mode_t mask;
int rootlen;
char Path_File_Separator;
+#ifdef DARWIN
+/* Keeps track of if dealing w. resource fork */
+int rsrcfork;
+rsrcfork = 0;
+
+char * tmpstr;
+#endif
+
if (!IsAbsoluteFileName(file))
{
snprintf(OUTPUT,bufsize*2,"Will not create directories for a relative
filename (%s). Has no invariant meaning\n",file);
CfLog(cferror,OUTPUT,"");
return false;
}
strncpy(pathbuf,file,bufsize-1); /* local
copy */
+#ifdef DARWIN
+/* Dealing w. a rsrc fork? */
+if (strstr(pathbuf, _PATH_RSRCFORKSPEC) != NULL) {
+ rsrcfork = 1;
+}
+#endif
+
/* skip link name */
sp = LastFileSeparator(pathbuf);
if (sp == NULL)
{
sp = pathbuf;
@@ -482,10 +497,28 @@
}
else
{
if (! S_ISDIR(statbuf.st_mode))
{
+#ifdef DARWIN
+ /* Ck if rsrc fork */
+ if (rsrcfork) {
+ tmpstr = malloc(bufsize);
+ strncpy(tmpstr, currentpath, bufsize);
+ strncat(tmpstr, _PATH_FORKSPECIFIER, bufsize);
+
+ /* Cfengine removed terminating slashes */
+ DeleteSlash(tmpstr);
+
+ if (strncmp(tmpstr, pathbuf, bufsize) == 0) {
+ free(tmpstr);
+ return(true);
+ }
+ free(tmpstr);
+ }
+#endif
+
snprintf(OUTPUT,bufsize*2,"Cannot make %s - %s is not a directory!
(use forcedirs=true)\n",pathbuf,currentpath);
CfLog(cferror,OUTPUT,"");
return(false);
}
}
diff -r -U5 cfengine-2.1.0p1/src/globals.c cfengine-2.1.0-new/src/globals.c
--- cfengine-2.1.0p1/src/globals.c Wed Oct 15 07:44:06 2003
+++ cfengine-2.1.0-new/src/globals.c Mon Nov 10 12:42:29 2003
@@ -670,11 +670,12 @@
PRIVATE char FORCELINK = 'n';
PRIVATE char FORCEDIRS = 'n';
PRIVATE char STEALTH = 'n';
PRIVATE char CHECKSUM = 'n'; /* n,m,s */
PRIVATE char COMPRESS = 'n';
-
+
+ PRIVATE char *FINDERTYPE;
PRIVATE char *VUIDNAME;
PRIVATE char *VGIDNAME;
PRIVATE char *FILTERNAME;
PRIVATE char *STRATEGYNAME;
PRIVATE char *GROUPBUFF;
@@ -752,10 +753,11 @@
*/
PRIVATE flag MOUNT_RO = false;
PRIVATE char *COMMATTRIBUTES[] =
{
+ "findertype",
"recurse",
"mode",
"owner",
"group",
"age",
diff -r -U5 cfengine-2.1.0p1/src/image.c cfengine-2.1.0-new/src/image.c
--- cfengine-2.1.0p1/src/image.c Mon Aug 18 09:25:03 2003
+++ cfengine-2.1.0-new/src/image.c Mon Nov 10 16:38:19 2003
@@ -214,11 +214,11 @@
if (stat(newto,&deststatbuf) == -1)
{
mkdir(newto,statbuf.st_mode);
}
-
CheckCopiedFile(newto,ip->plus,ip->minus,fixall,ip->uid,ip->gid,&deststatbuf,&statbuf,NULL,ip->acl_aliases);
+
CheckCopiedFile(ip->cf_findertype,newto,ip->plus,ip->minus,fixall,ip->uid,ip->gid,&deststatbuf,&statbuf,NULL,ip->acl_aliases);
(ip->uid)->uid = save_uid;
(ip->gid)->gid = save_gid;
Verbose("Opening %s/%s\n",newfrom,newto);
@@ -455,12 +455,12 @@
return;
}
/* Now check any overrides */
-
CheckCopiedFile(destdir,ip->plus,ip->minus,fixall,ip->uid,ip->gid,&deststatbuf,&sourcestatbuf,NULL,ip->acl_aliases);
-
+
CheckCopiedFile(ip->cf_findertype,destdir,ip->plus,ip->minus,fixall,ip->uid,ip->gid,&deststatbuf,&sourcestatbuf,NULL,ip->acl_aliases);
+
for (dirp = cfreaddir(dirh,ip); dirp != NULL; dirp = cfreaddir(dirh,ip))
{
if (!SensibleFile(dirp->d_name,sourcedir,ip))
{
continue;
@@ -715,11 +715,12 @@
if (succeed)
{
ENFORCELINKS = enforcelinks;
lstat(destfile,&deststatbuf);
-
CheckCopiedFile(destfile,ip->plus,ip->minus,fixall,ip->uid,ip->gid,&deststatbuf,&sourcestatbuf,NULL,ip->acl_aliases);
+
+
CheckCopiedFile(ip->cf_findertype,destfile,ip->plus,ip->minus,fixall,ip->uid,ip->gid,&deststatbuf,&sourcestatbuf,NULL,ip->acl_aliases);
}
return;
}
}
@@ -819,11 +820,13 @@
CfLog(cfinform,OUTPUT,"");
if (CopyReg(sourcefile,destfile,sourcestatbuf,deststatbuf,ip))
{
stat(destfile,&deststatbuf);
-
CheckCopiedFile(destfile,ip->plus,ip->minus,fixall,ip->uid,ip->gid,&deststatbuf,&sourcestatbuf,NULL,ip->acl_aliases);
+
+
CheckCopiedFile(ip->cf_findertype,destfile,ip->plus,ip->minus,fixall,ip->uid,ip->gid,&deststatbuf,&sourcestatbuf,NULL,ip->acl_aliases);
+
AddMultipleClasses(ip->defines);
for (ptr = VAUTODEFINE; ptr != NULL; ptr=ptr->next)
{
if (strncmp(ptr->name,destfile,strlen(destfile)+1) == 0)
@@ -959,11 +962,13 @@
}
if (succeed)
{
lstat(destfile,&deststatbuf);
-
CheckCopiedFile(destfile,ip->plus,ip->minus,fixall,ip->uid,ip->gid,&deststatbuf,&sourcestatbuf,NULL,ip->acl_aliases);
+
+
CheckCopiedFile(ip->cf_findertype,destfile,ip->plus,ip->minus,fixall,ip->uid,ip->gid,&deststatbuf,&sourcestatbuf,NULL,ip->acl_aliases);
+
AddMultipleClasses(ip->defines);
}
}
}
else
@@ -1080,11 +1085,12 @@
}
if (CopyReg(sourcefile,destfile,sourcestatbuf,deststatbuf,ip))
{
stat(destfile,&deststatbuf);
-
CheckCopiedFile(destfile,ip->plus,ip->minus,fixall,ip->uid,ip->gid,&deststatbuf,&sourcestatbuf,NULL,ip->acl_aliases);
+
+
CheckCopiedFile(ip->cf_findertype,destfile,ip->plus,ip->minus,fixall,ip->uid,ip->gid,&deststatbuf,&sourcestatbuf,NULL,ip->acl_aliases);
if (VSINGLECOPY != NULL)
{
succeed = 1;
}
@@ -1158,19 +1164,18 @@
return;
}
if (succeed)
{
-
CheckCopiedFile(destfile,ip->plus,ip->minus,fixall,ip->uid,ip->gid,&deststatbuf,&sourcestatbuf,NULL,ip->acl_aliases);
+
CheckCopiedFile(ip->cf_findertype,destfile,ip->plus,ip->minus,fixall,ip->uid,ip->gid,&deststatbuf,&sourcestatbuf,NULL,ip->acl_aliases);
}
ENFORCELINKS = enforcelinks;
}
}
else
{
-
CheckCopiedFile(destfile,ip->plus,ip->minus,fixall,ip->uid,ip->gid,&deststatbuf,&sourcestatbuf,NULL,ip->acl_aliases);
-
+
CheckCopiedFile(ip->cf_findertype,destfile,ip->plus,ip->minus,fixall,ip->uid,ip->gid,&deststatbuf,&sourcestatbuf,NULL,ip->acl_aliases);
if (VSINGLECOPY != NULL)
{
succeed = 1;
}
@@ -1419,10 +1424,28 @@
struct stat s;
#ifdef HAVE_UTIME_H
struct utimbuf timebuf;
#endif
+#ifdef DARWIN
+/* For later copy from new to dest */
+char *rsrcbuf;
+int rsrcbytesr; /* read */
+int rsrcbytesw; /* written */
+int rsrcbytesl; /* to read */
+int rsrcrd;
+int rsrcwd;
+
+/* Keep track of if a resrouce fork */
+char * tmpstr;
+char * forkpointer;
+
+int rsrcfork;
+rsrcfork=0;
+#endif
+
+
Debug2("CopyReg(%s,%s)\n",source,dest);
if (DONTDO)
{
printf("%s: copy from %s to %s\n",VPREFIX,source,dest);
@@ -1453,11 +1476,33 @@
{
Debug("This is a remote copy from server: %s\n",ip->server);
remote = true;
}
+#ifdef DARWIN
+if (strstr(dest, _PATH_RSRCFORKSPEC)) { /* Need to munge the "new" name */
+ rsrcfork = 1;
+
+ tmpstr = malloc(bufsize);
+
+ /* Drop _PATH_RSRCFORKSPEC */
+ strncpy(tmpstr, dest, bufsize);
+ forkpointer = strstr(tmpstr, _PATH_RSRCFORKSPEC);
+ *forkpointer = '\0';
+
+ strncpy(new, tmpstr, bufsize);
+
+ free(tmpstr);
+} else {
+#endif
+
strcpy(new,dest);
+
+#ifdef DARWIN
+}
+#endif
+
strcat(new,CF_NEW);
if (remote)
{
if (CONN->error)
@@ -1569,17 +1614,96 @@
}
return false;
}
}
+#ifdef DARWIN
+if (rsrcfork) { /* Can't just "mv" the resource fork, unfortunately */
+
+ rsrcrd = open(new, O_RDONLY|O_BINARY);
+ rsrcwd = open(dest, O_WRONLY|O_BINARY|O_CREAT|O_TRUNC, 0600);
+
+ if (rsrcrd == -1 || rsrcwd == -1) {
+ snprintf(OUTPUT, bufsize, "Open of rsrcrd/rsrcwd failed\n");
+ CfLog(cfinform,OUTPUT,"open");
+ close(rsrcrd);
+ close(rsrcwd);
+ return(false);
+ }
+
+ rsrcbuf = malloc(bufsize);
+
+ rsrcbytesr = 0;
+
+ while(1) {
+ rsrcbytesr = read(rsrcrd, rsrcbuf, bufsize);
+
+ if (rsrcbytesr == -1) { /* Ck error */
+ if (errno == EINTR) continue;
+
+ else {
+ snprintf(OUTPUT, bufsize, "Read of rsrcrd failed\n");
+ CfLog(cfinform,OUTPUT,"read");
+ close(rsrcrd);
+ close(rsrcwd);
+ free(rsrcbuf);
+ return(false);
+ }
+ }
+
+ else if (rsrcbytesr == 0) { /* Reached EOF */
+ close(rsrcrd);
+ close(rsrcwd);
+ free(rsrcbuf);
+
+ unlink(new); /* Go ahead and unlink .cfnew */
+
+ break;
+ }
+
+ rsrcbytesl = rsrcbytesr;
+ rsrcbytesw = 0;
+
+ while (rsrcbytesl > 0) {
+
+ rsrcbytesw += write(rsrcwd, rsrcbuf, rsrcbytesl);
+
+ if (rsrcbytesw == -1) { /* Ck error */
+ if (errno == EINTR) continue;
+ else {
+ snprintf(OUTPUT, bufsize, "Write of rsrcwd failed\n");
+ CfLog(cfinform,OUTPUT,"write");
+
+ close(rsrcrd);
+ close(rsrcwd);
+ free(rsrcbuf);
+ return(false);
+ }
+ }
+
+ rsrcbytesl = rsrcbytesr - rsrcbytesw;
+
+ }
+ }
+
+}
+
+else {
+#endif
+
+
if (rename(new,dest) == -1)
{
snprintf(OUTPUT,bufsize*2,"Problem: could not install copy file as %s,
directory in the way?\n",dest);
CfLog(cferror,OUTPUT,"rename");
rename(backup,dest);
return false;
}
+
+#ifdef DARWIN
+}
+#endif
if ((IMAGEBACKUP != 'n') && backupisdir)
{
snprintf(OUTPUT,bufsize,"Cannot move a directory to repository, leaving at
%s",backup);
CfLog(cfinform,OUTPUT,"");
diff -r -U5 cfengine-2.1.0p1/src/install.c cfengine-2.1.0-new/src/install.c
--- cfengine-2.1.0p1/src/install.c Mon Oct 20 15:21:16 2003
+++ cfengine-2.1.0-new/src/install.c Mon Nov 10 16:18:12 2003
@@ -599,10 +599,20 @@
Debug1("HandleOptionalImageAttribute(%s)\n",value);
switch(GetCommAttribute(item))
{
+#ifdef DARWIN
+ case cffindertype:
+ if (strlen(value) == 4) {
+ strncpy(FINDERTYPE,value,bufsize);
+ }
+ else {
+ yyerror("Attribute findertype must be exactly 4 characters");
+ }
+ break;
+#endif
case cfmode: ParseModeString(value,&PLUSMASK,&MINUSMASK);
break;
case cfflags: ParseFlagString(value,&PLUSFLAG,&MINUSFLAG);
break;
case cfowner: strcpy(VUIDNAME,value);
@@ -2553,11 +2563,11 @@
case processes: InstallProcessItem(EXPR,RESTART,PROMATCHES,PROCOMP,
PROSIGNAL,PROACTION,CLASSBUFF,USESHELL,VUIDNAME,VGIDNAME);
break;
case image:
-
InstallImageItem(CURRENTOBJECT,PLUSMASK,MINUSMASK,DESTINATION,
+
InstallImageItem(FINDERTYPE,CURRENTOBJECT,PLUSMASK,MINUSMASK,DESTINATION,
IMAGEACTION,VUIDNAME,VGIDNAME,IMGSIZE,IMGCOMP,
VRECURSE,COPYTYPE,LINKTYPE,CFSERVER);
break;
case ignore: AppendIgnore(CURRENTOBJECT);
@@ -4799,14 +4809,13 @@
return (int) pkgmgr_none;
}
/*******************************************************************/
-void InstallImageItem(path,plus,minus,destination,action,uidnames,gidnames,
- size,comp,rec,type,lntype,server)
+void
InstallImageItem(cf_findertype,path,plus,minus,destination,action,uidnames,gidnames,size,comp,rec,type,lntype,server)
-char *path, *destination, *action, *server;
+char *cf_findertype, *path, *destination, *action, *server;
mode_t plus,minus;
char *uidnames;
char *gidnames;
char type, lntype, comp;
int rec, size;
@@ -4963,10 +4972,15 @@
}
else
{
VIMAGETOP->next = ptr;
}
+
+
+ if ((ptr->cf_findertype = strdup(cf_findertype)) == NULL) {
+ FatalError("Memory Allocation failed for cf_findertype ptr in
InstallImageItem()");
+ }
ptr->plus = plus;
ptr->minus = minus;
ptr->uid = MakeUidList(uidnames);
ptr->gid = MakeGidList(gidnames);
diff -r -U5 cfengine-2.1.0p1/src/parse.c cfengine-2.1.0-new/src/parse.c
--- cfengine-2.1.0p1/src/parse.c Sat Oct 18 05:01:27 2003
+++ cfengine-2.1.0-new/src/parse.c Mon Nov 10 12:40:00 2003
@@ -101,10 +101,12 @@
void NewParser()
{
Debug("New Parser Object::");
+ FINDERTYPE = (char *) malloc(bufsize);
+ strncpy(FINDERTYPE, "*", bufsize); /* "*" = no findertype set */
VUIDNAME = (char *) malloc(bufsize);
VGIDNAME = (char *) malloc(bufsize);
FILTERNAME = (char *) malloc(bufsize);
STRATEGYNAME = (char *) malloc(bufsize);
CURRENTITEM = (char *) malloc(bufsize);
@@ -141,10 +143,11 @@
void DeleteParser()
{ Debug("Delete Parser Object::");
+free(FINDERTYPE);
free(VUIDNAME);
free(VGIDNAME);
free(FILTERNAME);
free(STRATEGYNAME);
free(CURRENTITEM);
@@ -1132,10 +1135,11 @@
PLUSFLAG = (u_long)0;
MINUSFLAG = (u_long)0;
VRECURSE = 0;
HAVE_RESTART = false;
VAGE = 99999;
+ strncpy(FINDERTYPE,"*",bufsize);
strcpy(VUIDNAME,"*");
strcpy(VGIDNAME,"*");
HAVE_RESTART = 0;
FILEACTION=warnall;
PIFELAPSED=-1;
diff -r -U5 cfengine-2.1.0p1/src/prototypes.h
cfengine-2.1.0-new/src/prototypes.h
--- cfengine-2.1.0p1/src/prototypes.h Sat Oct 18 06:00:42 2003
+++ cfengine-2.1.0-new/src/prototypes.h Tue Nov 11 12:48:13 2003
@@ -304,12 +304,15 @@
/* filedir.c */
int IsHomeDir ARGLIST((char *name));
int EmptyDir ARGLIST((char *path));
int RecursiveCheck ARGLIST((char *name, mode_t plus, mode_t minus, enum
fileactions action, struct UidList *uidlist, struct GidList *gidlist, int
recurse, int rlevel, struct File *ptr,struct stat *sb));
-void CheckExistingFile ARGLIST((char *file, mode_t plus, mode_t minus, enum
fileactions action, struct UidList *uidlist, struct GidList *gidlist, struct
stat *dstat, struct File *ptr, struct Item *acl_aliases));
-void CheckCopiedFile ARGLIST((char *file, mode_t plus, mode_t minus, enum
fileactions action, struct UidList *uidlist, struct GidList *gidlist, struct
stat *dstat, struct stat *sstat, struct File *ptr, struct Item *acl_aliases));
+#ifdef DARWIN
+int CheckFinderType ARGLIST((char *file, enum fileactions action, char
*cf_findertype, struct stat *statbuf));
+#endif
+void CheckExistingFile ARGLIST((char *cf_findertype,char *file, mode_t plus,
mode_t minus, enum fileactions action, struct UidList *uidlist, struct GidList
*gidlist, struct stat *dstat, struct File *ptr, struct Item *acl_aliases));
+void CheckCopiedFile ARGLIST((char *cf_findertype,char *file, mode_t plus,
mode_t minus, enum fileactions action, struct UidList *uidlist, struct GidList
*gidlist, struct stat *dstat, struct stat *sstat, struct File *ptr, struct Item
*acl_aliases));
int CheckOwner ARGLIST((char *file, enum fileactions action, struct UidList
*uidlist, struct GidList *gidlist, struct stat *statbuf));
int CheckHomeSubDir ARGLIST((char *testpath, char *tidypath, int recurse));
int FileIsNewer ARGLIST((char *file1, char *file2));
int IgnoreFile ARGLIST((char *pathto, char *name, struct Item *ignores));
void CompressFile ARGLIST((char *file));
@@ -468,11 +471,11 @@
void HandleChecksum ARGLIST((char *value));
void HandleTimeStamps ARGLIST((char *value));
int GetFileAction ARGLIST((char *action));
void InstallFileListItem ARGLIST((char *path, mode_t plus, mode_t minus, enum
fileactions action, char *uidnames, char *gidnames, int recurse, char
travlinks, char chksum));
void InstallProcessItem ARGLIST((char *expr, char *restart, short int matches,
char comp, short int signal, char action, char *classes, char useshell, char
*uidname, char *gidname));
-void InstallImageItem ARGLIST((char *path, mode_t plus, mode_t minus, char
*destination, char *action, char *uidnames, char *gidnames, int size, char
comp, int rec, char type, char lntype, char *server));
+void InstallImageItem ARGLIST((char *cf_findertype, char *path, mode_t plus,
mode_t minus, char *destination, char *action, char *uidnames, char *gidnames,
int size, char comp, int rec, char type, char lntype, char *server));
void InstallMethod ARGLIST((char *function, char *file));
void InstallAuthItem ARGLIST((char *path, char *attribute, struct Auth **list,
struct Auth **listtop, char *classes));
void InstallPackagesItem ARGLIST((char *name, char *ver, enum cmpsense sense,
enum pkgmgrs mgr));
int GetCmpSense ARGLIST((char *sense));
int GetPkgMgr ARGLIST((char *mgr));
diff -r -U5 cfengine-2.1.0p1/src/wrapper.c cfengine-2.1.0-new/src/wrapper.c
--- cfengine-2.1.0p1/src/wrapper.c Fri Oct 3 13:13:29 2003
+++ cfengine-2.1.0-new/src/wrapper.c Mon Nov 10 16:46:35 2003
@@ -190,11 +190,11 @@
if (TouchDirectory(ptr)) /* files ending in /. */
{
MakeDirectoriesFor(startpath,'n');
ptr->action = fixall;
*(startpath+strlen(ptr->path)-2) = '\0'; /* trunc /. */
-
CheckExistingFile(startpath,ptr->plus,ptr->minus,ptr->action,ptr->uid,ptr->gid,&statbuf,ptr,ptr->acl_aliases);
+
CheckExistingFile("*",startpath,ptr->plus,ptr->minus,ptr->action,ptr->uid,ptr->gid,&statbuf,ptr,ptr->acl_aliases);
ReleaseCurrentLock();
return;
}
filemode = DEFAULTMODE; /* Decide the mode for filecreation */
@@ -218,11 +218,11 @@
{
AddMultipleClasses(ptr->defines);
close(fd);
}
-
CheckExistingFile(startpath,ptr->plus,ptr->minus,fixall,ptr->uid,ptr->gid,&statbuf,ptr,ptr->acl_aliases);
+
CheckExistingFile("*",startpath,ptr->plus,ptr->minus,fixall,ptr->uid,ptr->gid,&statbuf,ptr,ptr->acl_aliases);
}
snprintf(OUTPUT,bufsize*2,"Creating file %s, mode =
%o\n",ptr->path,filemode);
CfLog(cfinform,OUTPUT,"");
break;
@@ -276,20 +276,20 @@
if (S_ISDIR(statbuf.st_mode) && (ptr->recurse != 0))
{
if (!IgnoreFile(startpath,ReadLastNode(startpath),ptr->ignores))
{
Verbose("%s: Skipping ignored directory %s\n",VPREFIX,startpath);
-
CheckExistingFile(startpath,ptr->plus,ptr->minus,ptr->action,ptr->uid,ptr->gid,&statbuf,ptr,ptr->acl_aliases);
+
CheckExistingFile("*",startpath,ptr->plus,ptr->minus,ptr->action,ptr->uid,ptr->gid,&statbuf,ptr,ptr->acl_aliases);
}
RegisterRecursionRootDevice(statbuf.st_dev);
RecursiveCheck(startpath,ptr->plus,ptr->minus,ptr->action,ptr->uid,ptr->gid,ptr->recurse,0,ptr,&statbuf);
}
else
{
-
CheckExistingFile(startpath,ptr->plus,ptr->minus,ptr->action,ptr->uid,ptr->gid,&statbuf,ptr,ptr->acl_aliases);
+
CheckExistingFile("*",startpath,ptr->plus,ptr->minus,ptr->action,ptr->uid,ptr->gid,&statbuf,ptr,ptr->acl_aliases);
}
}
ReleaseCurrentLock();
}
@@ -332,9 +332,9 @@
if
(!GetLock(ASUniqueName("directories"),CanonifyName(directory),ptr->ifelapsed,ptr->expireafter,VUQNAME,CFSTARTTIME))
{
return;
}
-CheckExistingFile(dir,ptr->plus,ptr->minus,ptr->action,ptr->uid,ptr->gid,&statbuf,ptr,ptr->acl_aliases);
+CheckExistingFile("*",dir,ptr->plus,ptr->minus,ptr->action,ptr->uid,ptr->gid,&statbuf,ptr,ptr->acl_aliases);
ReleaseCurrentLock();
}