]> git.pld-linux.org Git - packages/rpm.git/blob - rpm-home_etc.patch
- updated amd64 patch
[packages/rpm.git] / rpm-home_etc.patch
1 diff -Nru rpm-4.1/lib/rpmrc.c rpm-4.1.new/lib/rpmrc.c
2 --- rpm-4.1/lib/rpmrc.c Tue Aug 20 16:53:44 2002
3 +++ rpm-4.1.new/lib/rpmrc.c     Tue Mar 11 18:41:48 2003
4 @@ -1756,27 +1756,40 @@
5         /* Expand ~/ to $HOME/ */
6         fn[0] = '\0';
7         if (r[0] == '~' && r[1] == '/') {
8 +                       const char * config_dir = getenv("CONFIG_DIR");
9             const char * home = getenv("HOME");
10 -           if (home == NULL) {
11 +                       if (config_dir) {
12 +               if (strlen(config_dir) > (sizeof(fn) - strlen(r))) {
13 +                                       rpmError(RPMERR_RPMRC, _("Cannot read %s, CONFIG_DIR is too large.\n"),r);
14 +                                       rc = 1;
15 +                                       break;
16 +               }
17 +               strcpy(fn, config_dir);
18 +                               strncat(fn, "/", sizeof(fn) - strlen(fn));                              
19 +                 r+=2;
20 +               
21 +                               if (r[0] == '.') r++;
22 +                       } else {
23 +               if (home == NULL) {
24             /* XXX Only /usr/lib/rpm/rpmrc must exist in default rcfiles list */
25 -               if (rcfiles == defrcfiles && myrcfiles != r)
26 -                   continue;
27 -               rpmError(RPMERR_RPMRC, _("Cannot expand %s\n"), r);
28 -               rc = 1;
29 -               break;
30 -           }
31 -           if (strlen(home) > (sizeof(fn) - strlen(r))) {
32 -               rpmError(RPMERR_RPMRC, _("Cannot read %s, HOME is too large.\n"),
33 +                       if (rcfiles == defrcfiles && myrcfiles != r)
34 +                       continue;
35 +                       rpmError(RPMERR_RPMRC, _("Cannot expand %s\n"), r);
36 +                       rc = 1;
37 +                       break;
38 +               }
39 +               if (strlen(home) > (sizeof(fn) - strlen(r))) {
40 +                       rpmError(RPMERR_RPMRC, _("Cannot read %s, HOME is too large.\n"),
41                                 r);
42 -               rc = 1;
43 -               break;
44 -           }
45 -           strcpy(fn, home);
46 -           r++;
47 -       }
48 -       strncat(fn, r, sizeof(fn) - (strlen(fn) + 1));
49 -       fn[sizeof(fn)-1] = '\0';
50 -
51 +                       rc = 1;
52 +                       break;
53 +               }
54 +               strcpy(fn, home);
55 +                 r++;
56 +                       }
57 +               }
58 +               strncat(fn, r, sizeof(fn) - (strlen(fn) + 1));
59 +               fn[sizeof(fn)-1] = '\0';
60         /* Read another rcfile */
61         fd = Fopen(fn, "r.fpio");
62         if (fd == NULL || Ferror(fd)) {
63 diff -Nru rpm-4.1/rpmio/macro.c rpm-4.1.new/rpmio/macro.c
64 --- rpm-4.1/rpmio/macro.c       Tue Sep 17 14:58:23 2002
65 +++ rpm-4.1.new/rpmio/macro.c   Tue Mar 11 18:21:59 2003
66 @@ -1614,15 +1614,23 @@
67         buf[0] = '\0';
68         if (mfile[0] == '~' && mfile[1] == '/') {
69             char *home;
70 -           if ((home = getenv("HOME")) != NULL) {
71 -               mfile += 2;
72 -               strncpy(buf, home, sizeof(buf));
73 -               strncat(buf, "/", sizeof(buf) - strlen(buf));
74 +                       char *config_dir = getenv("CONFIG_DIR");
75 +
76 +                       if (config_dir) {
77 +                               mfile += 2;
78 +                               if (mfile[0] == '.') mfile++;
79 +                               strncpy(buf, config_dir, sizeof(buf));
80 +                               strncat(buf, "/", sizeof(buf) - strlen(buf));                           
81 +                       } else {
82 +               if ((home = getenv("HOME")) != NULL) {
83 +                       mfile += 2;
84 +                       strncpy(buf, home, sizeof(buf));
85 +                       strncat(buf, "/", sizeof(buf) - strlen(buf));
86             }
87 +               }
88         }
89         strncat(buf, mfile, sizeof(buf) - strlen(buf));
90         buf[sizeof(buf)-1] = '\0';
91 -
92         fd = Fopen(buf, "r.fpio");
93         if (fd == NULL || Ferror(fd)) {
94             if (fd) (void) Fclose(fd);
This page took 0.037847 seconds and 3 git commands to generate.