~ubuntu-branches/ubuntu/lucid/vsftpd/lucid-201001052349

« back to all changes in this revision

Viewing changes to secutil.c

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2005-03-23 15:52:34 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050323155234-00xobn5vcl0nwozg
Tags: 2.0.1-1ubuntu1
pretty init scriptage

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * Part of Very Secure FTPd
3
 
 * Licence: GPL
 
3
 * Licence: GPL v2
4
4
 * Author: Chris Evans
5
5
 * secutil.c
6
6
 */
15
15
void
16
16
vsf_secutil_change_credentials(const struct mystr* p_user_str,
17
17
                               const struct mystr* p_dir_str,
 
18
                               const struct mystr* p_ext_dir_str,
18
19
                               unsigned int caps, unsigned int options)
19
20
{
20
21
  struct vsf_sysutil_user* p_user;
25
26
  p_user = str_getpwnam(p_user_str);
26
27
  if (p_user == 0)
27
28
  {
28
 
    die("str_getpwnam");
 
29
    die2("cannot locate user entry:", str_getbuf(p_user_str));
29
30
  }
30
31
  {
31
32
    struct mystr dir_str = INIT_MYSTR;
32
33
    /* Work out where the chroot() jail is */
33
 
    if (p_dir_str == 0)
 
34
    if (p_dir_str == 0 || str_isempty(p_dir_str))
34
35
    {
35
36
      str_alloc_text(&dir_str, vsf_sysutil_user_get_homedir(p_user));
36
37
    }
67
68
      retval = str_chdir(&dir_str);
68
69
      if (retval != 0)
69
70
      {
70
 
        die("chdir");
 
71
        die2("cannot change directory:", str_getbuf(&dir_str));
 
72
      }
 
73
      if (p_ext_dir_str && !str_isempty(p_ext_dir_str))
 
74
      {
 
75
        retval = str_chdir(p_ext_dir_str);
 
76
        /* Failure on the extra directory is OK as long as we're not in
 
77
         * chroot() mode
 
78
         */
 
79
        if (retval != 0 && !(options & VSF_SECUTIL_OPTION_CHROOT))
 
80
        {
 
81
          retval = 0;
 
82
        }
 
83
      }
 
84
      if (retval != 0)
 
85
      {
 
86
        die2("cannot change directory:", str_getbuf(p_ext_dir_str));
71
87
      }
72
88
      if (options & VSF_SECUTIL_OPTION_CHANGE_EUID)
73
89
      {