extract.c (81982) | extract.c (84745) |
---|---|
1#ifndef lint 2static const char rcsid[] = | 1#ifndef lint 2static const char rcsid[] = |
3 "$FreeBSD: head/usr.sbin/pkg_install/add/extract.c 81982 2001-08-20 15:09:34Z brian $"; | 3 "$FreeBSD: head/usr.sbin/pkg_install/add/extract.c 84745 2001-10-10 06:58:42Z sobomax $"; |
4#endif 5 6/* 7 * FreeBSD install - a package for the installation and maintainance 8 * of non-core utilities. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions --- 12 unchanged lines hidden (view full) --- 24 */ 25 26#include <err.h> 27#include "lib.h" 28#include "add.h" 29 30 31#define STARTSTRING "tar cf - " | 4#endif 5 6/* 7 * FreeBSD install - a package for the installation and maintainance 8 * of non-core utilities. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions --- 12 unchanged lines hidden (view full) --- 24 */ 25 26#include <err.h> 27#include "lib.h" 28#include "add.h" 29 30 31#define STARTSTRING "tar cf - " |
32#define TOOBIG(str) ((strlen(str) + FILENAME_MAX + where_count > maxargs) \ 33 || (strlen(str) + FILENAME_MAX + perm_count > maxargs)) | 32#define TOOBIG(str) (((int)strlen(str) + FILENAME_MAX + where_count > maxargs) \ 33 || ((int)strlen(str) + FILENAME_MAX + perm_count > maxargs)) |
34 35#define PUSHOUT(todir) /* push out string */ \ | 34 35#define PUSHOUT(todir) /* push out string */ \ |
36 if (where_count > sizeof(STARTSTRING)-1) { \ | 36 if (where_count > (int)sizeof(STARTSTRING)-1) { \ |
37 strcat(where_args, "|tar --unlink -xf - -C "); \ 38 strcat(where_args, todir); \ 39 if (system(where_args)) { \ 40 cleanup(0); \ | 37 strcat(where_args, "|tar --unlink -xf - -C "); \ 38 strcat(where_args, todir); \ 39 if (system(where_args)) { \ 40 cleanup(0); \ |
41 errx(2, __FUNCTION__ ": can not invoke %d byte tar pipeline: %s", \ 42 strlen(where_args), where_args); \ | 41 errx(2, __FUNCTION__ ": can not invoke %ld byte tar pipeline: %s", \ 42 (long)strlen(where_args), where_args); \ |
43 } \ 44 strcpy(where_args, STARTSTRING); \ 45 where_count = sizeof(STARTSTRING)-1; \ 46 } \ 47 if (perm_count) { \ 48 apply_perms(todir, perm_args); \ 49 perm_args[0] = 0;\ 50 perm_count = 0; \ 51 } 52 53static void | 43 } \ 44 strcpy(where_args, STARTSTRING); \ 45 where_count = sizeof(STARTSTRING)-1; \ 46 } \ 47 if (perm_count) { \ 48 apply_perms(todir, perm_args); \ 49 perm_args[0] = 0;\ 50 perm_count = 0; \ 51 } 52 53static void |
54rollback(char *name, char *home, PackingList start, PackingList stop) | 54rollback(const char *name, const char *home, PackingList start, PackingList stop) |
55{ 56 PackingList q; | 55{ 56 PackingList q; |
57 char try[FILENAME_MAX], bup[FILENAME_MAX], *dir; | 57 char try[FILENAME_MAX], bup[FILENAME_MAX]; 58 const char *dir; |
58 59 dir = home; 60 for (q = start; q != stop; q = q->next) { 61 if (q->type == PLIST_FILE) { 62 snprintf(try, FILENAME_MAX, "%s/%s", dir, q->name); 63 if (make_preserve_name(bup, FILENAME_MAX, name, try) && fexists(bup)) { 64 (void)chflags(try, 0); 65 (void)unlink(try); --- 6 unchanged lines hidden (view full) --- 72 dir = q->name; 73 else 74 dir = home; 75 } 76 } 77} 78 79void | 59 60 dir = home; 61 for (q = start; q != stop; q = q->next) { 62 if (q->type == PLIST_FILE) { 63 snprintf(try, FILENAME_MAX, "%s/%s", dir, q->name); 64 if (make_preserve_name(bup, FILENAME_MAX, name, try) && fexists(bup)) { 65 (void)chflags(try, 0); 66 (void)unlink(try); --- 6 unchanged lines hidden (view full) --- 73 dir = q->name; 74 else 75 dir = home; 76 } 77 } 78} 79 80void |
80extract_plist(char *home, Package *pkg) | 81extract_plist(const char *home, Package *pkg) |
81{ 82 PackingList p = pkg->head; 83 char *last_file; 84 char *where_args, *perm_args, *last_chdir; 85 int maxargs, where_count = 0, perm_count = 0, add_count; 86 Boolean preserve; 87 88 maxargs = sysconf(_SC_ARG_MAX) / 2; /* Just use half the argument space */ --- 15 unchanged lines hidden (view full) --- 104 last_chdir = 0; 105 preserve = find_plist_option(pkg, "preserve") ? TRUE : FALSE; 106 107 /* Reset the world */ 108 Owner = NULL; 109 Group = NULL; 110 Mode = NULL; 111 last_file = NULL; | 82{ 83 PackingList p = pkg->head; 84 char *last_file; 85 char *where_args, *perm_args, *last_chdir; 86 int maxargs, where_count = 0, perm_count = 0, add_count; 87 Boolean preserve; 88 89 maxargs = sysconf(_SC_ARG_MAX) / 2; /* Just use half the argument space */ --- 15 unchanged lines hidden (view full) --- 105 last_chdir = 0; 106 preserve = find_plist_option(pkg, "preserve") ? TRUE : FALSE; 107 108 /* Reset the world */ 109 Owner = NULL; 110 Group = NULL; 111 Mode = NULL; 112 last_file = NULL; |
112 Directory = home; | 113 (const char *)Directory = home; |
113 114 /* Do it */ 115 while (p) { 116 char cmd[FILENAME_MAX]; 117 118 switch(p->type) { 119 case PLIST_NAME: 120 PkgName = p->name; --- 81 unchanged lines hidden (view full) --- 202 if (strcmp(p->name, ".")) { 203 if (!Fake && make_hierarchy(p->name) == FAIL) { 204 cleanup(0); 205 errx(2, __FUNCTION__ ": unable to cwd to '%s'", p->name); 206 } 207 Directory = p->name; 208 } 209 else | 114 115 /* Do it */ 116 while (p) { 117 char cmd[FILENAME_MAX]; 118 119 switch(p->type) { 120 case PLIST_NAME: 121 PkgName = p->name; --- 81 unchanged lines hidden (view full) --- 203 if (strcmp(p->name, ".")) { 204 if (!Fake && make_hierarchy(p->name) == FAIL) { 205 cleanup(0); 206 errx(2, __FUNCTION__ ": unable to cwd to '%s'", p->name); 207 } 208 Directory = p->name; 209 } 210 else |
210 Directory = home; | 211 (const char *)Directory = home; |
211 break; 212 213 case PLIST_CMD: 214 if ((strstr(p->name, "%B") || strstr(p->name, "%F") || 215 strstr(p->name, "%f")) && last_file == NULL) { 216 cleanup(0); 217 errx(2, __FUNCTION__ ": no last file specified for '%s' command", p->name); 218 } --- 41 unchanged lines hidden --- | 212 break; 213 214 case PLIST_CMD: 215 if ((strstr(p->name, "%B") || strstr(p->name, "%F") || 216 strstr(p->name, "%f")) && last_file == NULL) { 217 cleanup(0); 218 errx(2, __FUNCTION__ ": no last file specified for '%s' command", p->name); 219 } --- 41 unchanged lines hidden --- |