summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2007-02-06 21:33:48 +0000
committerSebastien Helleu <flashcode@flashtux.org>2007-02-06 21:33:48 +0000
commit6d01968259a92cc1a62cb313742b22b5c1178788 (patch)
treecccd65115fd906ec1b7aa6bddc3ce63381deae33 /src
parentfddd0416b9136fadcfe2667f7a485d50c0150f1a (diff)
downloadweechat-6d01968259a92cc1a62cb313742b22b5c1178788.zip
Fixed permissions on "dcc" and "logs" directories (bug #18978)
Diffstat (limited to 'src')
-rw-r--r--src/common/weechat.c25
1 files changed, 7 insertions, 18 deletions
diff --git a/src/common/weechat.c b/src/common/weechat.c
index 4d7754766..3df0d197f 100644
--- a/src/common/weechat.c
+++ b/src/common/weechat.c
@@ -445,7 +445,7 @@ weechat_parse_args (int argc, char *argv[])
*/
int
-weechat_create_dir (char *directory)
+weechat_create_dir (char *directory, int permissions)
{
if (mkdir (directory, 0755) < 0)
{
@@ -456,7 +456,10 @@ weechat_create_dir (char *directory)
WEECHAT_ERROR, directory);
return 0;
}
+ return 1;
}
+ if ((permissions != 0) && (strcmp (directory, getenv ("HOME")) != 0))
+ chmod (directory, permissions);
return 1;
}
@@ -505,7 +508,7 @@ weechat_create_home_dirs ()
}
/* create home directory; error is fatal */
- if (!weechat_create_dir (weechat_home))
+ if (!weechat_create_dir (weechat_home, 0))
{
weechat_iconv_fprintf (stderr, _("%s unable to create \"%s\" directory\n"),
WEECHAT_ERROR, weechat_home);
@@ -525,14 +528,7 @@ weechat_create_config_dirs ()
/* create logs directory" */
dir1 = weechat_strreplace (cfg_log_path, "~", getenv ("HOME"));
dir2 = weechat_strreplace (dir1, "%h", weechat_home);
- if (weechat_create_dir (dir2))
- {
- if (strcmp (dir2, getenv ("HOME")) != 0)
- chmod (dir2, 0700);
- }
- else
- weechat_iconv_fprintf (stderr, _("%s unable to create \"%s\" directory\n"),
- WEECHAT_WARNING, dir2);
+ (void) weechat_create_dir (dir2, 0700);
if (dir1)
free (dir1);
if (dir2)
@@ -541,14 +537,7 @@ weechat_create_config_dirs ()
/* create DCC download directory */
dir1 = weechat_strreplace (cfg_dcc_download_path, "~", getenv ("HOME"));
dir2 = weechat_strreplace (dir1, "%h", weechat_home);
- if (weechat_create_dir (dir2))
- {
- if (strcmp (dir2, getenv ("HOME")) != 0)
- chmod (dir2, 0700);
- }
- else
- weechat_iconv_fprintf (stderr, _("%s unable to create \"%s\" directory\n"),
- WEECHAT_WARNING, dir2);
+ (void) weechat_create_dir (dir2, 0700);
if (dir1)
free (dir1);
if (dir2)