38 if (Line[1]==
'r') Mode |= S_IRUSR;
40 if (Line[2]==
'w') Mode |= S_IWUSR;
42 if (Line[3]==
'x') Mode |= S_IXUSR;
43 if (Line[3]==
's') Mode |= S_IXUSR | S_ISUID;
44 if (Line[3]==
'S') Mode |= S_ISUID;
46 if (Line[4]==
'r') Mode |= S_IRGRP;
48 if (Line[5]==
'w') Mode |= S_IWGRP;
50 if (Line[6]==
'x') Mode |= S_IXGRP;
51 if (Line[6]==
's') Mode |= S_IXGRP | S_ISGID;
52 if (Line[6]==
'S') Mode |= S_ISGID;
54 if (Line[7]==
'r') Mode |= S_IROTH;
56 if (Line[8]==
'w') Mode |= S_IWOTH;
58 if (Line[9]==
'x') Mode |= S_IXOTH;
59 if (Line[9]==
't') Mode |= S_IXOTH | S_ISVTX;
60 if (Line[9]==
'T') Mode |= S_ISVTX;
81 char Cmd[FILENAME_MAX*5];
82 char Line[FILENAME_MAX];
87 char TempSource[FILENAME_MAX], TempDestination[FILENAME_MAX];
90 if ((NULL == Source) || (!strcmp(Source,
"")) || (NULL == Destination) || (!strcmp(Destination,
"")))
93 if (!
Quiet &&
Verbose) fprintf(stderr,
"Extracting ISO: %s\n",Source);
96 if (
TaintString(TempSource,FILENAME_MAX,Source,1,NULL) ||
97 TaintString(TempDestination,FILENAME_MAX,Destination,1,NULL))
99 memset(Cmd,
'\0',
sizeof(Cmd));
100 snprintf(Cmd,
sizeof(Cmd),
" (isoinfo -l -R -J -i '%s' || isoinfo -l -R -i '%s' " 101 "|| isoinfo -l -i '%s') 2>/dev/null | grep '^Directory'",
102 TempSource, TempSource, TempSource);
105 Fin = popen(Cmd,
"r");
108 fprintf(stderr,
"ERROR: ISO failed: %s\n",Cmd);
111 while(
ReadLine(Fin,Line,
sizeof(Line)-1) >= 0)
114 if (s==NULL)
continue;
115 snprintf(Cmd,
sizeof(Cmd),
"%s%s",Destination,s);
116 if (
Verbose > 1) printf(
"ISO directory: %s\n",Cmd);
119 fprintf(stderr,
"ERROR: Unable to mkdir(%s) in ExtractISO\n",Cmd);
126 snprintf(Cmd,
sizeof(Cmd),
"(isoinfo -f -R -J -i '%s' || isoinfo -f -R -i '%s' || isoinfo -f -i '%s') 2>/dev/null",
127 TempSource, TempSource, TempSource);
129 Fin = popen(Cmd,
"r");
132 fprintf(stderr,
"ERROR: ISO failed: %s\n",Cmd);
136 memset(Line,
'\0',
sizeof(Line));
137 strcpy(Line,Destination);
138 Len=strlen(Destination);
139 while(
ReadLine(Fin,Line+Len,
sizeof(Line)-1-Len) >= 0)
141 if (Line[Len] !=
'/')
continue;
142 if (
IsDir(Line))
continue;
143 if (
Verbose > 1) printf(
"ISO file: %s\n",Line);
145 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);
149 printf(
"ERROR: Process killed by signal (%d): %s\n",WTERMSIG(rc),Cmd);
152 rc = WEXITSTATUS(rc);
155 fprintf(stderr,
"ERROR: Command failed (rc=%d): %s\n",rc,Cmd);
165 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",
166 TempSource, TempSource, TempSource, TempDestination);
170 printf(
"ERROR: Process killed by signal (%d): %s\n",WTERMSIG(rc),Cmd);
173 rc = WEXITSTATUS(rc);
176 fprintf(stderr,
"ERROR: Command failed (rc=%d): %s\n",rc,Cmd);
184 snprintf(Cmd,
sizeof(Cmd),
"(isoinfo -l -R -J -i '%s' || isoinfo -l -R -i '%s' || isoinfo -l -i '%s') 2>/dev/null",
185 TempSource, TempSource, TempSource);
186 Fin = popen(Cmd,
"r");
190 char Dir[FILENAME_MAX];
191 memset(Dir,
'\0',
sizeof(Dir));
192 while((Len =
ReadLine(Fin,Line,
sizeof(Line)-1)) >= 0)
194 if (Len == 0)
continue;
195 if (!strchr(
"Dd-",Line[0]))
continue;
197 if (!strncmp(Line,
"Directory listing of ",21))
202 snprintf(Cmd,
sizeof(Cmd)-1,
"%s/%s%s",Destination,Dir,Line+67);
int Quiet
Run in quiet mode?
int IsDir(char *Fname)
Given a filename, is it a directory?
int Verbose
Verbose level.
int ExtractISO(char *Source, char *Destination)
Given an ISO image and a directory, extract the image to the directory.
int s
The socket that the CLI will use to communicate.
mode_t GetISOMode(char *Line)
Given a line in drwxrwxrwx format, convert it to a numeric mode.
int MkDir(char *Fname)
Smart mkdir.
Stores all extern variables used by the agent.
char * TaintString(char *S)
Create a string with taint quoting.
int ReadLine(FILE *Fin, char *Line, int MaxLine)
void SafeExit(int rc)
Close scheduler and database connections, then exit.
int ForceContinue
Force continue when unpack tool fails?