mirror of
https://github.com/moparisthebest/pacman
synced 2024-12-23 08:18:51 -05:00
Log commandline in pacman/alpm log
This implements FS#11452. Original-work-by: silvio <silvio@port1024.net> Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
6e1b1aea59
commit
c88ac86292
@ -957,6 +957,29 @@ static int parseconfig(const char *file)
|
||||
return(_parseconfig(file, NULL, NULL));
|
||||
}
|
||||
|
||||
/** print commandline to logfile
|
||||
*/
|
||||
static void cl_to_log(int argc, char* argv[])
|
||||
{
|
||||
size_t size = 0;
|
||||
int i;
|
||||
for(i = 0; i<argc; i++) {
|
||||
size += strlen(argv[i]) + 1;
|
||||
}
|
||||
char *cl_text = malloc(size);
|
||||
if(!cl_text)
|
||||
return;
|
||||
char *p = cl_text;
|
||||
for(i = 0; i<argc-1; i++) {
|
||||
strcpy(p, argv[i]);
|
||||
p += strlen(argv[i]);
|
||||
*p++ = ' ';
|
||||
}
|
||||
strcpy(p, argv[i]);
|
||||
alpm_logaction("Running '%s'\n", cl_text);
|
||||
free(cl_text);
|
||||
}
|
||||
|
||||
/** Main function.
|
||||
* @param argc argc
|
||||
* @param argv argv
|
||||
@ -1083,6 +1106,11 @@ int main(int argc, char *argv[])
|
||||
cleanup(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Log commandline */
|
||||
if(needs_root()) {
|
||||
cl_to_log(argc, argv);
|
||||
}
|
||||
|
||||
/* start the requested operation */
|
||||
switch(config->op) {
|
||||
case PM_OP_REMOVE:
|
||||
|
Loading…
Reference in New Issue
Block a user