libpurple/protocols/silc/util.c

changeset 21389
e1dd8142bb87
parent 21115
1cf273ed6eda
child 21453
a90cf329cd48
equal deleted inserted replaced
21388:108195e86aa3 21389:e1dd8142bb87
77 struct passwd *pw; 77 struct passwd *pw;
78 int fd; 78 int fd;
79 79
80 pw = getpwuid(getuid()); 80 pw = getpwuid(getuid());
81 if (!pw) { 81 if (!pw) {
82 purple_debug_error("silc", "silc: %s\n", strerror(errno)); 82 purple_debug_error("silc", "silc: %s\n", g_strerror(errno));
83 return FALSE; 83 return FALSE;
84 } 84 }
85 85
86 g_snprintf(filename, sizeof(filename) - 1, "%s", silcpurple_silcdir()); 86 g_snprintf(filename, sizeof(filename) - 1, "%s", silcpurple_silcdir());
87 g_snprintf(servfilename, sizeof(servfilename) - 1, "%s" G_DIR_SEPARATOR_S "serverkeys", 87 g_snprintf(servfilename, sizeof(servfilename) - 1, "%s" G_DIR_SEPARATOR_S "serverkeys",
106 purple_debug_error("silc", "Couldn't create '%s' directory due to a wrong uid!\n", 106 purple_debug_error("silc", "Couldn't create '%s' directory due to a wrong uid!\n",
107 filename); 107 filename);
108 return FALSE; 108 return FALSE;
109 } 109 }
110 } else { 110 } else {
111 purple_debug_error("silc", "Couldn't stat '%s' directory, error: %s\n", filename, strerror(errno)); 111 purple_debug_error("silc", "Couldn't stat '%s' directory, error: %s\n", filename, g_strerror(errno));
112 return FALSE; 112 return FALSE;
113 } 113 }
114 } else { 114 } else {
115 #ifndef _WIN32 115 #ifndef _WIN32
116 /* Check the owner of the dir */ 116 /* Check the owner of the dir */
138 servfilename); 138 servfilename);
139 return FALSE; 139 return FALSE;
140 } 140 }
141 } else { 141 } else {
142 purple_debug_error("silc", "Couldn't stat '%s' directory, error: %s\n", 142 purple_debug_error("silc", "Couldn't stat '%s' directory, error: %s\n",
143 servfilename, strerror(errno)); 143 servfilename, g_strerror(errno));
144 return FALSE; 144 return FALSE;
145 } 145 }
146 } 146 }
147 147
148 /* 148 /*
161 clientfilename); 161 clientfilename);
162 return FALSE; 162 return FALSE;
163 } 163 }
164 } else { 164 } else {
165 purple_debug_error("silc", "Couldn't stat '%s' directory, error: %s\n", 165 purple_debug_error("silc", "Couldn't stat '%s' directory, error: %s\n",
166 clientfilename, strerror(errno)); 166 clientfilename, g_strerror(errno));
167 return FALSE; 167 return FALSE;
168 } 168 }
169 } 169 }
170 170
171 /* 171 /*
184 friendsfilename); 184 friendsfilename);
185 return FALSE; 185 return FALSE;
186 } 186 }
187 } else { 187 } else {
188 purple_debug_error("silc", "Couldn't stat '%s' directory, error: %s\n", 188 purple_debug_error("silc", "Couldn't stat '%s' directory, error: %s\n",
189 friendsfilename, strerror(errno)); 189 friendsfilename, g_strerror(errno));
190 return FALSE; 190 return FALSE;
191 } 191 }
192 } 192 }
193 193
194 /* 194 /*
216 return FALSE; 216 return FALSE;
217 } 217 }
218 218
219 if ((g_stat(file_public_key, &st)) == -1) { 219 if ((g_stat(file_public_key, &st)) == -1) {
220 purple_debug_error("silc", "Couldn't stat '%s' public key, error: %s\n", 220 purple_debug_error("silc", "Couldn't stat '%s' public key, error: %s\n",
221 file_public_key, strerror(errno)); 221 file_public_key, g_strerror(errno));
222 return FALSE; 222 return FALSE;
223 } 223 }
224 } else { 224 } else {
225 purple_debug_error("silc", "Couldn't stat '%s' public key, error: %s\n", 225 purple_debug_error("silc", "Couldn't stat '%s' public key, error: %s\n",
226 file_public_key, strerror(errno)); 226 file_public_key, g_strerror(errno));
227 return FALSE; 227 return FALSE;
228 } 228 }
229 } 229 }
230 230
231 #ifndef _WIN32 231 #ifndef _WIN32
237 #endif 237 #endif
238 238
239 if ((fd = g_open(file_private_key, O_RDONLY, 0)) != -1) { 239 if ((fd = g_open(file_private_key, O_RDONLY, 0)) != -1) {
240 if ((fstat(fd, &st)) == -1) { 240 if ((fstat(fd, &st)) == -1) {
241 purple_debug_error("silc", "Couldn't stat '%s' private key, error: %s\n", 241 purple_debug_error("silc", "Couldn't stat '%s' private key, error: %s\n",
242 file_private_key, strerror(errno)); 242 file_private_key, g_strerror(errno));
243 close(fd); 243 close(fd);
244 return FALSE; 244 return FALSE;
245 } 245 }
246 } else if ((g_stat(file_private_key, &st)) == -1) { 246 } else if ((g_stat(file_private_key, &st)) == -1) {
247 /* If file doesn't exist */ 247 /* If file doesn't exist */
259 } 259 }
260 260
261 if ((fd = g_open(file_private_key, O_RDONLY, 0)) != -1) { 261 if ((fd = g_open(file_private_key, O_RDONLY, 0)) != -1) {
262 if ((fstat(fd, &st)) == -1) { 262 if ((fstat(fd, &st)) == -1) {
263 purple_debug_error("silc", "Couldn't stat '%s' private key, error: %s\n", 263 purple_debug_error("silc", "Couldn't stat '%s' private key, error: %s\n",
264 file_private_key, strerror(errno)); 264 file_private_key, g_strerror(errno));
265 close(fd); 265 close(fd);
266 return FALSE; 266 return FALSE;
267 } 267 }
268 } 268 }
269 /* This shouldn't really happen because silc_create_key_pair() 269 /* This shouldn't really happen because silc_create_key_pair()
270 * will set the permissions */ 270 * will set the permissions */
271 else if ((g_stat(file_private_key, &st)) == -1) { 271 else if ((g_stat(file_private_key, &st)) == -1) {
272 purple_debug_error("silc", "Couldn't stat '%s' private key, error: %s\n", 272 purple_debug_error("silc", "Couldn't stat '%s' private key, error: %s\n",
273 file_private_key, strerror(errno)); 273 file_private_key, g_strerror(errno));
274 return FALSE; 274 return FALSE;
275 } 275 }
276 } else { 276 } else {
277 purple_debug_error("silc", "Couldn't stat '%s' private key, error: %s\n", 277 purple_debug_error("silc", "Couldn't stat '%s' private key, error: %s\n",
278 file_private_key, strerror(errno)); 278 file_private_key, g_strerror(errno));
279 return FALSE; 279 return FALSE;
280 } 280 }
281 } 281 }
282 282
283 #ifndef _WIN32 283 #ifndef _WIN32

mercurial