Skip to content
Snippets Groups Projects
Commit 76caa895 authored by Denis Pynkin's avatar Denis Pynkin
Browse files

Do not include package on removal

parent 8c1aba71
No related branches found
No related tags found
No related merge requests found
......@@ -140,7 +140,7 @@ static int conf_files_filter(const struct dirent *entry){
return(st.st_mode & S_IFREG);
}
int read_common_conf() {
int read_common_conf(args_t *args) {
char fname[FILENAME_SIZE];
DIR *dir;
int entries;
......@@ -156,6 +156,11 @@ int read_common_conf() {
if(configs[entries]->d_name == NULL)
continue;
/* Do not read the config on package removal */
if( args->remove &&
strcmp(configs[entries]->d_name, args->package_name) == 0)
continue;
snprintf(fname, sizeof(fname), "%s/%s", configdir, configs[entries]->d_name);
DBGPRINT("Config found: %s\n", fname);
free(configs[entries]);
......
......@@ -34,7 +34,7 @@ int main(int argc, char **argv) {
if(init_common_conf()){
exit(1);
}
if(read_common_conf()){
if(read_common_conf(&args)){
exit(1);
}
......
......@@ -6,6 +6,7 @@
#include <getopt.h>
#include <string.h>
#include <stdlib.h>
#include <pam-auth-update.h>
#include <parse_args.h>
......@@ -74,7 +75,8 @@ int parse_args(args_t *args, int argc, char **argv){
}
/* get the name of package from environment */
if(args->package) {
if(args->package || args->remove) {
args->package_name = getenv("DPKG_MAINTSCRIPT_NAME");
}
/* Set default system values if not set via command line */
......
......@@ -13,7 +13,7 @@ typedef struct args {
int force;
int remove;
int package;
char package_name[256];
char *package_name;
} args_t;
int parse_args(args_t *args, int argc, char **argv);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment