diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2007-09-02 16:12:49 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 15:03:32 -0500 |
commit | dcb925bba737ab0ee7b5f45032eeba88b9305c6f (patch) | |
tree | daa7c677ce15f344ce07ad85315323ca24920212 /source4 | |
parent | e561313888452a17117956cc4532b77055f20b36 (diff) | |
download | samba-dcb925bba737ab0ee7b5f45032eeba88b9305c6f.tar.gz samba-dcb925bba737ab0ee7b5f45032eeba88b9305c6f.tar.bz2 samba-dcb925bba737ab0ee7b5f45032eeba88b9305c6f.zip |
r24897: Do some sanity checking on --basedir.
(This used to be commit 32dbaa142a2514d011a91ba0a0026934305e295f)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/torture/smbtorture.c | 15 | ||||
-rw-r--r-- | source4/torture/util.c | 5 |
2 files changed, 17 insertions, 3 deletions
diff --git a/source4/torture/smbtorture.c b/source4/torture/smbtorture.c index 6fbd824ecb..e629ded5c2 100644 --- a/source4/torture/smbtorture.c +++ b/source4/torture/smbtorture.c @@ -651,7 +651,20 @@ int main(int argc,char *argv[]) } torture = torture_context_init(talloc_autofree_context(), ui_ops); - torture->outputdir = basedir; + if (basedir != NULL) { + if (basedir[0] != '/') { + fprintf(stderr, "Please specify an absolute path to --basedir\n"); + return 1; + } + torture->outputdir = basedir; + } else { + char *pwd = talloc_size(torture, PATH_MAX); + if (!getcwd(pwd, PATH_MAX)) { + fprintf(stderr, "Unable to determine current working directory\n"); + return 1; + } + torture->outputdir = pwd; + } if (argc_new == 0) { printf("You must specify a test to run, or 'ALL'\n"); diff --git a/source4/torture/util.c b/source4/torture/util.c index f6287e34d6..b8bfa5f51f 100644 --- a/source4/torture/util.c +++ b/source4/torture/util.c @@ -28,9 +28,10 @@ create a temporary directory. */ _PUBLIC_ NTSTATUS torture_temp_dir(struct torture_context *tctx, - const char *prefix, - char **tempdir) + const char *prefix, + char **tempdir) { + SMB_ASSERT(tctx->outputdir != NULL); *tempdir = talloc_asprintf(tctx, "%s/%s.XXXXXX", tctx->outputdir, prefix); if (mkdtemp(*tempdir) == NULL) |