int main(int argc, const char *const *argv) { int ret; dpkg_locales_init(PACKAGE); dpkg_program_init("dpkg"); dpkg_options_load(DPKG, cmdinfos); dpkg_options_parse(&argv, cmdinfos, printforhelp); if (!cipaction) badusage(_("need an action option")); admindir = dpkg_db_set_dir(admindir); /* Always set environment, to avoid possible security risks. */ if (setenv("DPKG_ADMINDIR", admindir, 1) < 0) ohshite(_("unable to setenv for subprocesses")); if (!f_triggers) f_triggers = (cipaction->arg_int == act_triggers && *argv) ? -1 : 1; if (is_invoke_action(cipaction->arg_int)) { run_invoke_hooks(cipaction->olong, pre_invoke_hooks); run_status_loggers(status_loggers); } filesdbinit(); ret = cipaction->action(argv); if (is_invoke_action(cipaction->arg_int)) run_invoke_hooks(cipaction->olong, post_invoke_hooks); dpkg_program_done(); return reportbroken_retexitstatus(ret); }
int main(int argc, const char *const *argv) { int ret; dpkg_locales_init(PACKAGE); dpkg_program_init("dpkg"); dpkg_options_load(DPKG, cmdinfos); dpkg_options_parse(&argv, cmdinfos, printforhelp); /* When running as root, make sure our primary group is also root, so * that files created by maintainer scripts have correct ownership. */ if (!fc_nonroot && getuid() == 0) if (setgid(0) < 0) ohshite(_("cannot set primary group ID to root")); if (!cipaction) badusage(_("need an action option")); admindir = dpkg_db_set_dir(admindir); /* Always set environment, to avoid possible security risks. */ if (setenv("DPKG_ADMINDIR", admindir, 1) < 0) ohshite(_("unable to setenv for subprocesses")); if (setenv("DPKG_ROOT", instdir, 1) < 0) ohshite(_("unable to setenv for subprocesses")); if (!f_triggers) f_triggers = (cipaction->arg_int == act_triggers && *argv) ? -1 : 1; if (is_invoke_action(cipaction->arg_int)) { run_invoke_hooks(cipaction->olong, &pre_invoke_hooks); run_status_loggers(&status_loggers); } filesdbinit(); ret = cipaction->action(argv); if (is_invoke_action(cipaction->arg_int)) run_invoke_hooks(cipaction->olong, &post_invoke_hooks); dpkg_program_done(); return reportbroken_retexitstatus(ret); }