Debian Codegraph @

debian/patches/011-pmvarrun-no-l0g

raw
1 Index: libpam-mount-2.14/src/pmvarrun.c
2 ===================================================================
3 --- a/src/pmvarrun.c
4 +++ b/src/pmvarrun.c
5 @@ -140,12 +140,12 @@ long str_to_long(const char *n)
6 long val;
7 char *endptr = NULL;
8 if (n == NULL) {
9 - l0g("count string is NULL\n");
10 + fprintf(stderr, "count string is NULL\n");
11 return LONG_MAX;
12 }
13 val = strtol(n, &endptr, 10);
14 if (*endptr != '\0') {
15 - l0g("count string is not valid\n");
16 + fprintf(stderr, "count string is not valid\n");
17 return LONG_MAX;
18 }
19 return val;
20 @@ -218,14 +218,14 @@ static int modify_pm_count(const char *user, long amount)
21
22 if ((pent = getpwnam(user)) == NULL) {
23 ret = -errno;
24 - l0g("could not resolve user %s\n", user);
25 + fprintf(stderr, "could not resolve user %s\n", user);
26 return ret;
27 }
28
29 if (stat(VAR_RUN_PMT, &sb) < 0) {
30 if (errno != ENOENT) {
31 ret = -errno;
32 - l0g("unable to stat " VAR_RUN_PMT ": %s\n",
33 + fprintf(stderr, "unable to stat " VAR_RUN_PMT ": %s\n",
34 strerror(errno));
35 return ret;
36 }
37 @@ -304,12 +304,12 @@ static int create_var_run(void)
38 w4rn("creating " VAR_RUN_PMT);
39 if (HX_mkdir(VAR_RUN_PMT, mode) < 0) {
40 ret = -errno;
41 - l0g("unable to create " VAR_RUN_PMT ": %s\n", strerror(errno));
42 + fprintf(stderr, "unable to create " VAR_RUN_PMT ": %s\n", strerror(errno));
43 return ret;
44 }
45 if (chown(VAR_RUN_PMT, 0, 0) < 0) {
46 ret = -errno;
47 - l0g("unable to chown " VAR_RUN_PMT ": %s\n", strerror(errno));
48 + fprintf(stderr, "unable to chown " VAR_RUN_PMT ": %s\n", strerror(errno));
49 return ret;
50 }
51
52 @@ -319,7 +319,7 @@ static int create_var_run(void)
53 */
54 if (chmod(VAR_RUN_PMT, mode) < 0) {
55 ret = -errno;
56 - l0g("unable to chmod " VAR_RUN_PMT ": %s\n", strerror(errno));
57 + fprintf(stderr, "unable to chmod " VAR_RUN_PMT ": %s\n", strerror(errno));
58 return ret;
59 }
60
61 @@ -347,12 +347,12 @@ static int open_and_lock(const char *filename, long uid) {
62
63 if ((fd = open(filename, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR)) < 0) {
64 ret = -errno;
65 - l0g("unable to open %s: %s\n", filename, strerror(errno));
66 + fprintf(stderr, "unable to open %s: %s\n", filename, strerror(errno));
67 return ret;
68 }
69 if (fchown(fd, uid, 0) < 0) {
70 ret = -errno;
71 - l0g("unable to chown %s: %s\n", filename, strerror(errno));
72 + fprintf(stderr, "unable to chown %s: %s\n", filename, strerror(errno));
73 return ret;
74 }
75
76 @@ -416,7 +416,7 @@ static long read_current_count(int fd, const char *filename) {
77
78 if ((ret = read(fd, buf, sizeof(buf))) < 0) {
79 ret = -errno;
80 - l0g("read error on %s: %s\n", filename, strerror(errno));
81 + fprintf(stderr, "read error on %s: %s\n", filename, strerror(errno));
82 close(fd);
83 return ret;
84 } else if (ret == 0) {
85 @@ -424,12 +424,12 @@ static long read_current_count(int fd, const char *filename) {
86 } else if (ret < sizeof(buf)) {
87 char *p;
88 if ((ret = strtol(buf, &p, 0)) >= LONG_MAX || p == buf) {
89 - l0g("parse problem / session count corrupt "
90 + fprintf(stderr, "parse problem / session count corrupt "
91 "(overflow), check your refcount file\n");
92 return -EOVERFLOW;
93 }
94 } else if (ret >= sizeof(buf)) {
95 - l0g("session count corrupt (overflow)\n");
96 + fprintf(stderr, "session count corrupt (overflow)\n");
97 return -EOVERFLOW;
98 }
99
100 @@ -440,7 +440,7 @@ static long read_current_count(int fd, const char *filename) {
101 * write_count -
102 * @fd: file descriptor to write to
103 * @nv: new value to write
104 - * @filename: filename, only used for l0g()
105 + * @filename: filename, only used for frpintf()
106 *
107 * Writes @nv as a number in hexadecimal to the start of the file @fd and
108 * truncates the file to the written length.
109 @@ -453,7 +453,7 @@ static int write_count(int fd, long nv, const char *filename) {
110 if (unlink(filename) >= 0)
111 return true;
112 if (errno != EPERM && errno != EACCES)
113 - l0g("could not unlink %s: %s\n", filename, strerror(errno));
114 + fprintf(stderr, "could not unlink %s: %s\n", filename, strerror(errno));
115 /*
116 * Fallback to just blanking the file. This can happen when
117 * pmvarrun is called as unprivileged user.
118 @@ -465,21 +465,21 @@ static int write_count(int fd, long nv, const char *filename) {
119
120 if ((ret = lseek(fd, 0, SEEK_SET)) != 0) {
121 ret = -errno;
122 - l0g("failed to seek in %s: %s\n", filename, strerror(errno));
123 + fprintf(stderr, "failed to seek in %s: %s\n", filename, strerror(errno));
124 return ret;
125 }
126
127 len = snprintf(buf, sizeof(buf), "0x%lX", nv);
128 if ((wrt = write(fd, buf, len)) != len) {
129 ret = -errno;
130 - l0g("wrote %d of %d bytes; write error on %s: %s\n",
131 + fprintf(stderr, "wrote %d of %d bytes; write error on %s: %s\n",
132 (wrt < 0) ? 0 : wrt, len, filename, strerror(errno));
133 return ret;
134 }
135
136 if (ftruncate(fd, len) < 0) {
137 ret = -errno;
138 - l0g("truncate failed: %s\n", strerror(errno));
139 + fprintf(stderr, "truncate failed: %s\n", strerror(errno));
140 return ret;
141 }
142