Deal with calling fork() without exec() in lua scriptlets.
Lua scriptlet is executed within rpm itself. So when no exec() is called after fork() in lua scriptlet then the forked process continues to run and duplicate the rest of the operations of the main rpm process. This behaviour is dangerous, it can lead to corrupted rpm database. This commit deals with this situation by terminating such a child process before execution of any duplicate operation.
This commit is contained in:
parent
4d41ad89af
commit
2d418ad3c1
|
@ -123,10 +123,16 @@ static rpmRC runLuaScript(rpmPlugins plugins, ARGV_const_t prefixes,
|
|||
if (cwd != -1) {
|
||||
mode_t oldmask = umask(0);
|
||||
umask(oldmask);
|
||||
pid_t pid = getpid();
|
||||
|
||||
if (chdir("/") == 0 && rpmluaRunScript(lua, script, sname) == 0) {
|
||||
rc = RPMRC_OK;
|
||||
}
|
||||
if (pid != getpid()) {
|
||||
/* Terminate child process forked in lua scriptlet */
|
||||
rpmlog(RPMLOG_ERR, _("No exec() called after fork() in lua scriptlet\n"));
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
/* This failing would be fatal, return something different for it... */
|
||||
if (fchdir(cwd)) {
|
||||
rpmlog(RPMLOG_ERR, _("Unable to restore current directory: %m"));
|
||||
|
|
Loading…
Reference in New Issue