summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-09-02 16:12:49 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 15:03:32 -0500
commitdcb925bba737ab0ee7b5f45032eeba88b9305c6f (patch)
treedaa7c677ce15f344ce07ad85315323ca24920212
parente561313888452a17117956cc4532b77055f20b36 (diff)
downloadsamba-dcb925bba737ab0ee7b5f45032eeba88b9305c6f.tar.gz
samba-dcb925bba737ab0ee7b5f45032eeba88b9305c6f.tar.bz2
samba-dcb925bba737ab0ee7b5f45032eeba88b9305c6f.zip
r24897: Do some sanity checking on --basedir.
(This used to be commit 32dbaa142a2514d011a91ba0a0026934305e295f)
-rw-r--r--source4/torture/smbtorture.c15
-rw-r--r--source4/torture/util.c5
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)