27 if (Line[1]==
'r') Mode |= S_IRUSR;
29 if (Line[2]==
'w') Mode |= S_IWUSR;
31 if (Line[3]==
'x') Mode |= S_IXUSR;
32 if (Line[3]==
's') Mode |= S_IXUSR | S_ISUID;
33 if (Line[3]==
'S') Mode |= S_ISUID;
35 if (Line[4]==
'r') Mode |= S_IRGRP;
37 if (Line[5]==
'w') Mode |= S_IWGRP;
39 if (Line[6]==
'x') Mode |= S_IXGRP;
40 if (Line[6]==
's') Mode |= S_IXGRP | S_ISGID;
41 if (Line[6]==
'S') Mode |= S_ISGID;
43 if (Line[7]==
'r') Mode |= S_IROTH;
45 if (Line[8]==
'w') Mode |= S_IWOTH;
47 if (Line[9]==
'x') Mode |= S_IXOTH;
48 if (Line[9]==
't') Mode |= S_IXOTH | S_ISVTX;
49 if (Line[9]==
'T') Mode |= S_ISVTX;
70 char Cmd[FILENAME_MAX*5];
71 char Line[FILENAME_MAX];
76 char TempSource[FILENAME_MAX], TempDestination[FILENAME_MAX];
79 if ((NULL == Source) || (!strcmp(Source,
"")) || (NULL == Destination) || (!strcmp(Destination,
"")))
82 if (!
Quiet &&
Verbose) fprintf(stderr,
"Extracting ISO: %s\n",Source);
85 if (
TaintString(TempSource,FILENAME_MAX,Source,1,NULL) ||
86 TaintString(TempDestination,FILENAME_MAX,Destination,1,NULL))
88 memset(Cmd,
'\0',
sizeof(Cmd));
89 snprintf(Cmd,
sizeof(Cmd),
" (isoinfo -l -R -J -i '%s' || isoinfo -l -R -i '%s' "
90 "|| isoinfo -l -i '%s') 2>/dev/null | grep '^Directory'",
91 TempSource, TempSource, TempSource);
97 fprintf(stderr,
"ERROR: ISO failed: %s\n",Cmd);
100 while(
ReadLine(Fin,Line,
sizeof(Line)-1) >= 0)
103 if (
s==NULL)
continue;
104 snprintf(Cmd,
sizeof(Cmd),
"%s%s",Destination,
s);
105 if (
Verbose > 1) printf(
"ISO directory: %s\n",Cmd);
108 fprintf(stderr,
"ERROR: Unable to mkdir(%s) in ExtractISO\n",Cmd);
115 snprintf(Cmd,
sizeof(Cmd),
"(isoinfo -f -R -J -i '%s' || isoinfo -f -R -i '%s' || isoinfo -f -i '%s') 2>/dev/null",
116 TempSource, TempSource, TempSource);
118 Fin = popen(Cmd,
"r");
121 fprintf(stderr,
"ERROR: ISO failed: %s\n",Cmd);
125 memset(Line,
'\0',
sizeof(Line));
126 strcpy(Line,Destination);
127 Len=strlen(Destination);
128 while(
ReadLine(Fin,Line+Len,
sizeof(Line)-1-Len) >= 0)
130 if (Line[Len] !=
'/')
continue;
131 if (
IsDir(Line))
continue;
132 if (
Verbose > 1) printf(
"ISO file: %s\n",Line);
134 snprintf(Cmd,
sizeof(Cmd),
"(isoinfo -R -J -i '%s' -x '%s' || isoinfo -R -i '%s' -x '%s' || isoinfo -i '%s' -x '%s') > '%s' 2>/dev/null",TempSource,Line+Len,TempSource,Line+Len,TempSource, Line+Len,Line);
138 printf(
"ERROR: Process killed by signal (%d): %s\n",WTERMSIG(rc),Cmd);
141 rc = WEXITSTATUS(rc);
144 fprintf(stderr,
"ERROR: Command failed (rc=%d): %s\n",rc,Cmd);
154 snprintf(Cmd,
sizeof(Cmd),
"(isoinfo -d -R -i '%s' || isoinfo -d -R -J -i '%s' || isoinfo -d -i '%s') > '%s/ISO_INFO' 2>/dev/null",
155 TempSource, TempSource, TempSource, TempDestination);
159 printf(
"ERROR: Process killed by signal (%d): %s\n",WTERMSIG(rc),Cmd);
162 rc = WEXITSTATUS(rc);
165 fprintf(stderr,
"ERROR: Command failed (rc=%d): %s\n",rc,Cmd);
173 snprintf(Cmd,
sizeof(Cmd),
"(isoinfo -l -R -J -i '%s' || isoinfo -l -R -i '%s' || isoinfo -l -i '%s') 2>/dev/null",
174 TempSource, TempSource, TempSource);
175 Fin = popen(Cmd,
"r");
179 char Dir[FILENAME_MAX];
180 memset(Dir,
'\0',
sizeof(Dir));
181 while((Len =
ReadLine(Fin,Line,
sizeof(Line)-1)) >= 0)
183 if (Len == 0)
continue;
184 if (!strchr(
"Dd-",Line[0]))
continue;
186 if (!strncmp(Line,
"Directory listing of ",21))
191 snprintf(Cmd,
sizeof(Cmd)-1,
"%s/%s%s",Destination,Dir,Line+67);
int Verbose
Verbose level.
Stores all extern variables used by the agent.
int Quiet
Run in quiet mode?
int ForceContinue
Force continue when unpack tool fails?
char * TaintString(char *S)
Create a string with taint quoting.
int s
The socket that the CLI will use to communicate.
int ReadLine(FILE *Fin, char *Line, int MaxLine)
int ExtractISO(char *Source, char *Destination)
Given an ISO image and a directory, extract the image to the directory.
mode_t GetISOMode(char *Line)
Given a line in drwxrwxrwx format, convert it to a numeric mode.
int MkDir(char *Fname)
Smart mkdir.
void SafeExit(int rc)
Close scheduler and database connections, then exit.
int IsDir(char *Fname)
Given a filename, is it a directory?