[BusyBox] problem with coreutils install

William Barsse wbarsse at pfn.com
Thu Jan 22 23:43:06 UTC 2004


Hi all,

I hope this hasn't been brought up before, but my quick search through 
the mail archive didn't pick it up.
when using the install command  :

# install -d -m0755 /var/lib/misc

I got :

 > install : cannot change ownership of (null): no such file or directory

there seems to be a small bug in install.c when it is called for a 
fully qualified path, the following patch should solve it. Hope this 
helps.

cheers,
- William

--- install.c.orig      2004-01-22 17:35:00.000000000 -0500
+++ install.c   2004-01-22 18:40:08.000000000 -0500
@@ -72,27 +72,34 @@

         /* Create directories */
         if (flags & INSTALL_OPT_DIRECTORY) {
-
                 for (argv += optind; *argv; argv++) {
                         unsigned char *dir_name = *argv;
-                       unsigned char *argv_ptr;
-
-                       ret |= bb_make_directory(dir_name, mode, 
FILEUTILS_RECUR);
-                       do {
-                               argv_ptr = strrchr(dir_name, '/');

-                               /* Skip the "." and ".." directories */
-                               if ((dir_name[0] == '.') && 
((dir_name[1] == '\0') || ((dir_name[1] == '.') && (dir_name[2] == 
'\0')))) {
-                                       break;
-                               }
-                               if (lchown(dir_name, uid, gid) == -1) {
-                                       bb_perror_msg("cannot change 
ownership of %s", argv_ptr);
-                                       ret |= EXIT_FAILURE;
-                               }
-                               if (argv_ptr) {
-                                       *argv_ptr = '\0';
-                               }
-                       } while (argv_ptr);
+                       ret |= bb_make_directory(dir_name, mode,
+                                                FILEUTILS_RECUR);
+                       if (flags & (INSTALL_OPT_OWNER | 
INSTALL_OPT_GROUP)) {
+                               unsigned char *argv_ptr;
+                               do {
+                                       /* Skip the "." and ".." 
directories */
+                                       /* and the empty string */
+                                       if ( (dir_name[0] == '\0') ||
+                                            ( (dir_name[0] == '.') &&
+                                              ( (dir_name[1] == '\0') 
||
+                                                ( (dir_name[1] == '.') 
&&
+                                                  (dir_name[2] == 
'\0'))))) {
+                                               break;
+                                       }
+                                       if (lchown(dir_name, uid, gid) 
== -1) {
+                                               bb_perror_msg("cannot 
change ownership of %s",
+                                                             dir_name);
+                                               ret |= EXIT_FAILURE;
+                                       }
+                                       argv_ptr = strrchr(dir_name, 
'/');
+                                       if (argv_ptr) {
+                                               *argv_ptr = '\0';
+                                       }
+                               } while(argv_ptr);
+                       }
                 }
                 return(ret);
         }




More information about the busybox mailing list