Lines 116-121
finish:
Link Here
|
116 |
fclose(f); |
116 |
fclose(f); |
117 |
return r; |
117 |
return r; |
118 |
|
118 |
|
|
|
119 |
#elif defined(TARGET_GENTOO) |
120 |
int r; |
121 |
FILE *f; |
122 |
|
123 |
assert(hn); |
124 |
|
125 |
if (!(f = fopen("/etc/conf.d/hostname", "re"))) |
126 |
return -errno; |
127 |
|
128 |
for (;;) { |
129 |
char line[LINE_MAX]; |
130 |
char *s, *k; |
131 |
|
132 |
if (!fgets(line, sizeof(line), f)) { |
133 |
if (feof(f)) |
134 |
break; |
135 |
|
136 |
r = -errno; |
137 |
goto finish; |
138 |
} |
139 |
|
140 |
s = strstrip(line); |
141 |
|
142 |
if (!startswith(s, "HOSTNAME=") && !startswith(s, "hostname=")) |
143 |
continue; |
144 |
|
145 |
if (!(k = strdup(s+9))) { |
146 |
r = -ENOMEM; |
147 |
goto finish; |
148 |
} |
149 |
if (!(k = delete_chars(k, "\"\'"))) { |
150 |
r = -ENOMEM; /* is ENOMEM correct here? */ |
151 |
goto finish; |
152 |
} |
153 |
|
154 |
*hn = k; |
155 |
break; |
156 |
} |
157 |
|
158 |
r = 0; |
159 |
|
160 |
finish: |
161 |
fclose(f); |
162 |
return r; |
163 |
|
119 |
#elif defined(TARGET_SUSE) |
164 |
#elif defined(TARGET_SUSE) |
120 |
int r; |
165 |
int r; |
121 |
char *s, *k; |
166 |
char *s, *k; |