]> sourceware.org Git - systemtap.git/commitdiff
staprun: reinstate -d '*' operation
authorFrank Ch. Eigler <fche@redhat.com>
Tue, 26 Apr 2016 21:02:33 +0000 (17:02 -0400)
committerFrank Ch. Eigler <fche@redhat.com>
Tue, 26 Apr 2016 21:10:03 +0000 (17:10 -0400)
PR14245 created a new relay_basedir_fd variable, for use when
staprun/stapio passes staprun a file descriptor for the base directory
of the sysfs systemtap-module directory.  (This is necessary in order
to get around 0700 mount-dir permissions.)  This broke staprun -d '*'
operation, since that variable got set (badly) once within the readdir
loop, and thence made actual removes inoperative.  Now we clear out
that variable so each actual module subdirectory will get a good
cleaning.

staprun/staprun.c

index 89e6d8be463cd65e57c97045bd31422659dfe673..c09e59b7c45e2be0e2da1aa25e1400a5b944b374 100644 (file)
@@ -229,9 +229,13 @@ static void remove_all_modules(void)
 
        moddir = opendir(base);
        if (moddir) {
-               while ((d = readdir(moddir)))
+               while ((d = readdir(moddir))) {
+                        if (strcmp(d->d_name, ".") == 0) continue;
+                        if (strcmp(d->d_name, "..") == 0) continue;
+                        relay_basedir_fd = -1; /* each time! */
                        if (remove_module(d->d_name, 0) == 0)
                                printf("Module %s removed.\n", d->d_name);
+                }
                closedir(moddir);
        }
 }
@@ -256,7 +260,8 @@ static int remove_module(const char *name, int verb)
         /* We call init_ctl_channel/close_ctl_channel to check whether
            the module is a systemtap-built one (having the right files),
            and that it's already unattached (because otherwise it'd EBUSY
-           the opens. */
+           the opens, and that it belongs to our uid (because otherwise
+           a faccessat(2) test on the .cmd file will fail). */
         ret = init_ctl_channel (name, 0);
         if (ret < 0) {
                 err("'%s' is not a zombie systemtap module.\n", name);
This page took 0.028747 seconds and 5 git commands to generate.