r24897: Do some sanity checking on --basedir.
authorJelmer Vernooij <jelmer@samba.org>
Sun, 2 Sep 2007 16:12:49 +0000 (16:12 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 20:03:32 +0000 (15:03 -0500)
(This used to be commit 32dbaa142a2514d011a91ba0a0026934305e295f)

source4/torture/smbtorture.c
source4/torture/util.c

index 6fbd824ecba7d6960acbc001dae4f134cf8e3ad7..e629ded5c2eccf370811bac84b119f5a511bf425 100644 (file)
@@ -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");
index f6287e34d6208d8952c4d90a5415c18a7b68b4da..b8bfa5f51f20c60ca1a9030b945968256c76d8c9 100644 (file)
  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)