summaryrefslogtreecommitdiff
path: root/lib/rpmscript.c
AgeCommit message (Collapse)AuthorFilesLines
2013-02-02Improving scriptlet related rpm plugin hooks.Elena Reshetova1-11/+27
Three new hooks added: PLUGINHOOK_SCRIPTLET_PRE_FUNC Called before scriptlet execution PLUGINHOOK_SCRIPTLET_FORK_POST_FUNC Called after fork() but before scriptlet execution PLUGINHOOK_SCRIPTLET_POST_FUNC Called after scriptlet execution Currently pre and post hooks are called for externals and internal lua scripts. post hook is called even if scriptlet execution has failed and the return code is given as an argument. fork_post hook is only called for external scriptlets, because for internal scriptlets no fork() is currently performed. Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
2013-02-02Extending rpm plugin interface, part 1Elena Reshetova1-6/+11
This change adds a new type of the rpm plugin, called transaction plugin and a set of initial hooks for this plugin. The hooks are: PLUGINHOOK_TSM_PRE Pre-transaction hook that is called before an rpm transaction begins PLUGINHOOK_TSM_POST Post-transaction hook that is called after an rpm transaction ends PLUGINHOOK_PSM_PRE Pre-transaction-element hook that is called before an rpm transaction-element is processed PLUGINHOOK_PSM_POST Post-transaction-element hook that is called after an rpm transaction-element is processed PLUGINHOOK_SCRIPT_SETUP Per-script hook that is called once for each rpm mainainers script that is present in the package Each hook is called for every plugin that have this hook registered. The avaliable transaction plugins can be specified in macros.in via transaction_plugins element. Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
2011-09-12Actually remember scriptlet flags in the rpmScript structPanu Matilainen1-2/+3
- Currently doesn't make any difference but since we actually have a flags member in the struct, might as well use it. Also we'll shortly be needing these during the actual execution too.
2011-09-12Rename scriptlet flags from RPMSCRIPT_FOO to RPMSCRIPT_FLAG_FOOPanu Matilainen1-2/+2
- No functional changes (and this is still internal-only API), just making more obvious what they are and clearing the RPMSCRIPT_FOO namespace for possible future use for the scriptlet types themselves.
2011-09-02Make rpmScript opaquePanu Matilainen1-0/+13
- Add accessor for fetching the script tag, the final piece that psm needs (and will continue to do so) from script internals. This allows the script type to become opaque for real.
2011-09-02Add an API for creating real rpmScript items out of triggers, use itPanu Matilainen1-2/+35
- Bury rpmScriptNew() into being internal helper in rpmscript - triggers and other scripts differ quite a bit in how their data is laid out in the header, especially args need "special attention". - Besides cleaning up things in the psm side, this technically makes trigger scripts runnable without having a header at hand. Of course currently trigger scripts are currently created and destroyed on the spot from headers so this is of academic interest...
2011-09-02First step towards unifying triggers into rpmScript APIPanu Matilainen1-21/+30
- Add a lower level script creation function to deal with the body expansions and such, use it for triggers as well. - This is still fairly ugly but its something that can be reasonably backported to 4.9.x which needs this too, as currently triggers are forgetting to set script->descr, causing "(null) failure" messages on glibc and on others, in would just crash on trigger failure and/or in debug verbosity level.
2011-05-30Fix a logic error leading to unlink(NULL) call, oops.Panu Matilainen1-1/+1
- If writing the scriptlet to a file fails, its possible to end up with non-NULL script but with NULL fn and kaboom in unlink()
2011-05-30Eliminate dead NULL-assignment on lua scriptlet executionPanu Matilainen1-3/+2
- alloc the luavar on entry, free on exit to remove any abuse possibilities
2011-05-28Eliminate dead NULL-assignments at scope-end in librpm, part IIIPanu Matilainen1-2/+2
- Remove NULL-assignments of local variables at the end of scope from the low-level helper machinery: fsm, psm, rpmscript and rpmrc
2011-05-03Use good ol' fork() + waitpid() for running scriptletsPanu Matilainen1-16/+15
- We have no need for anything fancier, this makes 80% of the overly complex & subtle semi-threaded and in places just broken code in rpmsq.[ch] unused and unnecessary.
2011-04-19Give at least some indication of error from fchdir() failuresPanu Matilainen1-3/+5
- Failure to return to current dir is likely to be lethal, at least log an error and return a different code for it.
2011-04-19Use rpmsqFork() return code instead of semi-private struct member for pidPanu Matilainen1-10/+9
- rpmsqFork() behaves like regular fork() in this regard so this just makes the code more obvious and eliminates an set-but-unused warning while at it.
2011-04-19Fclose() and unlink() errors aren't fatal here, just ignorePanu Matilainen1-2/+2
2011-04-19Catch write errors when generating scriptlet temporary filesPanu Matilainen1-13/+28
- If the write fails scripts are likely to fail anyway, but executing partial scriptlets (unlikely as that might be) could have funny side-effects besides just failing. - Also cleans up runExtScript() a little bit by moving the tmp file creation to a separate function.
2011-01-28Add an error message + comments on open(".") behavior (RhBug:672576)Panu Matilainen1-0/+1
- Bail out early and complain if current directory can't be open()'ed, as we'll need it for reliable cwd restoration after running Lua scripts. - Technically we'd only need open(".") succeeding for chroot operations and running Lua-scripts, but there's no easy way to determine whether a transaction will run Lua-scripts. They could be in-db triggers which will only be evaluated in the middle of transaction, better to fail early for consistent behavior.
2010-11-18Only force default umask during transaction (RhBug:494440)Panu Matilainen1-1/+5
- For rpm itself forging global umask on init is kinda convenient, but can be troublesome for API users. This is especially bad in python bindings where just importing the rpm module silently changes process umask with no good reason. - Instead of global setting on init, only change the umask to 022 default for the duration of rpmtsRun() where it's necessary for consistent transaction results on implicitly created directories and files created by scriptlets. This way we dont affect callers and provide better "protection" for ourselves too - we don't know if API users change umask again behind our back if we just set it on initialization. - To make matters more fun, Lua scripts can change our umask. Save and restore umask when running Lua scriptlets.
2010-10-22Switch psm and rpmscript to use rpmTagVal where appropriatePanu Matilainen1-5/+5
- There are a few true rpmTag uses though, leaving them as they are...
2010-10-22Eliminate silly castPanu Matilainen1-1/+1
2010-05-26Eliminate rpmts from the scriptlet machineryPanu Matilainen1-15/+11
- pass scriptFd and selinux enabled status as arguments from psm level - selinux status could be queried directly with is_selinux_enabled() but that's a fairly expensive call which does all sorts of funny things and probably doesn't work at all in the average chroot - Lua-scripts dont currently honor scriptFd and have no use for selinux but pass the info there too as an early step towards supporting scriptFd with Lua - makes rpmScriptRun() even more of an argument monster, some of this should probably go into rpmScript struct...
2010-05-26Simplify chroot handling wrt scriptletsPanu Matilainen1-45/+14
- switch root if necessary on entry and exit to psm already, nothing inside the psm needs access to outside chroot - eliminate chroot handling from scriptlet machinery, dealing with chroot is a job for higher levels - Lua scriptlets can change our cwd, always ensure we return to previous cwd after executing by saving and restoring the cwd
2010-05-25Move scriptlet statistics collection (back) inside psmPanu Matilainen1-2/+0
- removes one rpmts dependency from scriptlets
2010-03-11Not all scriptlets have bodies (eg -p /sbin/ldconfig), dont expand NULLsPanu Matilainen1-2/+3
2010-03-11Support run-time macro and queryformat expansion on scriptletsPanu Matilainen1-1/+31
- Add per-scriptlet type flag tags to control special behavior. - Add rpmlib dependency on scriptlet expansion - if a package relies on scriptlet expansion it cannot be correctly installed with a version of rpm that doesn't support it. - Expansion is always an opt-in behavior, enabled with -q and/or -e argument in spec. We can't just blindly expand even macros as there's no telling %{} constructs might mean in whatever language is used for the script. - Queryformat expansion requires great care with strange and ugly escapes when writing scriptlets, but OTOH it permits access arbitrary header data at runtime, which has previously been completely impossible. - The handling of these expansions needs unifying for all scriptlet types, the trigger scriptlet handling is uuugly. Macro expansion could be transparently done from rpmScriptRun(), but because of their similar syntax, macro expansion needs to happen before query format expansion, and we dont have the header available in rpmScriptrun()
2010-02-25First rough-cut version of scriptlet abstractionPanu Matilainen1-0/+399
- Split the low-level scriptlet machinery out of psm - New struct to hold the necessary information about scriptlets so we can execute them without having a header at hand. - Trigger handling is hackish and needs more love...