~ubuntu-branches/ubuntu/intrepid/weechat/intrepid-security

« back to all changes in this revision

Viewing changes to src/common/weechat.c

  • Committer: Bazaar Package Importer
  • Author(s): Julien Louis
  • Date: 2007-03-29 21:01:46 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20070329210146-5lrzre36om1e0263
Tags: 0.2.4-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
445
445
 */
446
446
 
447
447
int
448
 
weechat_create_dir (char *directory)
 
448
weechat_create_dir (char *directory, int permissions)
449
449
{
450
450
    if (mkdir (directory, 0755) < 0)
451
451
    {
456
456
                                   WEECHAT_ERROR, directory);
457
457
            return 0;
458
458
        }
 
459
        return 1;
459
460
    }
 
461
    if ((permissions != 0) && (strcmp (directory, getenv ("HOME")) != 0))
 
462
        chmod (directory, permissions);
460
463
    return 1;
461
464
}
462
465
 
505
508
    }
506
509
    
507
510
    /* create home directory; error is fatal */
508
 
    if (!weechat_create_dir (weechat_home))
 
511
    if (!weechat_create_dir (weechat_home, 0))
509
512
    {
510
513
        weechat_iconv_fprintf (stderr, _("%s unable to create \"%s\" directory\n"),
511
514
                               WEECHAT_ERROR, weechat_home);
525
528
    /* create logs directory" */
526
529
    dir1 = weechat_strreplace (cfg_log_path, "~", getenv ("HOME"));
527
530
    dir2 = weechat_strreplace (dir1, "%h", weechat_home);
528
 
    if (weechat_create_dir (dir2))
529
 
    {
530
 
        if (strcmp (dir2, getenv ("HOME")) != 0)
531
 
            chmod (dir2, 0700);
532
 
    }
533
 
    else
534
 
        weechat_iconv_fprintf (stderr, _("%s unable to create \"%s\" directory\n"),
535
 
                               WEECHAT_WARNING, dir2);
 
531
    (void) weechat_create_dir (dir2, 0700);
536
532
    if (dir1)
537
533
        free (dir1);
538
534
    if (dir2)
541
537
    /* create DCC download directory */
542
538
    dir1 = weechat_strreplace (cfg_dcc_download_path, "~", getenv ("HOME"));
543
539
    dir2 = weechat_strreplace (dir1, "%h", weechat_home);
544
 
    if (weechat_create_dir (dir2))
545
 
    {
546
 
        if (strcmp (dir2, getenv ("HOME")) != 0)
547
 
            chmod (dir2, 0700);
548
 
    }
549
 
    else
550
 
        weechat_iconv_fprintf (stderr, _("%s unable to create \"%s\" directory\n"),
551
 
                               WEECHAT_WARNING, dir2);
 
540
    (void) weechat_create_dir (dir2, 0700);
552
541
    if (dir1)
553
542
        free (dir1);
554
543
    if (dir2)
865
854
    gui_main_end ();                    /* shut down WeeChat GUI            */
866
855
    weechat_shutdown (EXIT_SUCCESS, 0); /* quit WeeChat (oh no, why?)       */
867
856
    
868
 
    return EXIT_SUCCESS;                /* make gcc happy (never executed)  */
 
857
    return EXIT_SUCCESS;                /* make C compiler happy            */
869
858
}