You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
lib/tst_tmpdir.c: force environment variable TMPDIR using an absolute pathname
In lib/tst_tmpdir.c, when TESTDIR is not an absolute patchname beginning with '/',
The corresponding code logic would be below:
if (TESTDIR[0] != '/') {
if (getcwd(current_dir, PATH_MAX) == NULL)
strncpy(parent_dir, TESTDIR, PATH_MAX);
else
sprintf(parent_dir, "%s/%s", current_dir, TESTDIR);
} else {
...
}
The statement "sprintf(parent_dir, "%s/%s", current_dir, TESTDIR);" is wrong,
because we can change to any directory in test case, which TESTDIR may no be
child directory of current_dir, we should fix this.
Now we decide to use absolute pathname for TMPDIR, this will greatly simplify
the code in tst_rmdir().
If we still want to use relative path in TMPDIR, we may change the code in tst_rmdir()
to chdir(test_start_work_dir) first, but this chdir() operation still will fail sometimes,
this is because some components' search permission in test_start_work_dir may be denied(
some test cases are run by root, but then may call setuid(), see access05.c). So I think
we should obey the rule 'fail fast', just using absolute pathname instead.
Though this may be not friendly to to usrs, users rarely export a different
TMPDIR other than /tmp, so it's OK.
Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
0 commit comments