commands/vcommand.cc
author "Tomas Zeman <tzeman@volny.cz>"
Wed, 16 Jan 2008 22:39:43 +0100
changeset 0 6f7a81934006
permissions -rw-r--r--
Imported vmailmgr-0.96.9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
6f7a81934006 Imported vmailmgr-0.96.9
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
     1
// Copyright (C) 1999,2000 Bruce Guenter <bruceg@em.ca>
6f7a81934006 Imported vmailmgr-0.96.9
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
     2
//
6f7a81934006 Imported vmailmgr-0.96.9
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
     3
// This program is free software; you can redistribute it and/or modify
6f7a81934006 Imported vmailmgr-0.96.9
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
     4
// it under the terms of the GNU General Public License as published by
6f7a81934006 Imported vmailmgr-0.96.9
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
     5
// the Free Software Foundation; either version 2 of the License, or
6f7a81934006 Imported vmailmgr-0.96.9
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
     6
// (at your option) any later version.
6f7a81934006 Imported vmailmgr-0.96.9
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
     7
//
6f7a81934006 Imported vmailmgr-0.96.9
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
     8
// This program is distributed in the hope that it will be useful,
6f7a81934006 Imported vmailmgr-0.96.9
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
     9
// but WITHOUT ANY WARRANTY; without even the implied warranty of
6f7a81934006 Imported vmailmgr-0.96.9
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    10
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6f7a81934006 Imported vmailmgr-0.96.9
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    11
// GNU General Public License for more details.
6f7a81934006 Imported vmailmgr-0.96.9
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    12
//
6f7a81934006 Imported vmailmgr-0.96.9
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    13
// You should have received a copy of the GNU General Public License
6f7a81934006 Imported vmailmgr-0.96.9
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    14
// along with this program; if not, write to the Free Software
6f7a81934006 Imported vmailmgr-0.96.9
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    15
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
6f7a81934006 Imported vmailmgr-0.96.9
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    16
6f7a81934006 Imported vmailmgr-0.96.9
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    17
#include <config.h>
6f7a81934006 Imported vmailmgr-0.96.9
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    18
#include <stdlib.h>
6f7a81934006 Imported vmailmgr-0.96.9
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    19
#include <unistd.h>
6f7a81934006 Imported vmailmgr-0.96.9
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    20
#include "vcommand.h"
6f7a81934006 Imported vmailmgr-0.96.9
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    21
#include "fdbuf/fdbuf.h"
6f7a81934006 Imported vmailmgr-0.96.9
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    22
6f7a81934006 Imported vmailmgr-0.96.9
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    23
extern const char* cli_program;
6f7a81934006 Imported vmailmgr-0.96.9
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    24
6f7a81934006 Imported vmailmgr-0.96.9
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    25
bool go_home()
6f7a81934006 Imported vmailmgr-0.96.9
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    26
{
6f7a81934006 Imported vmailmgr-0.96.9
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    27
  if(!user.home) {
6f7a81934006 Imported vmailmgr-0.96.9
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    28
    ferr << cli_program << ": Can't determine home directory" << endl;
6f7a81934006 Imported vmailmgr-0.96.9
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    29
    return false;
6f7a81934006 Imported vmailmgr-0.96.9
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    30
  }
6f7a81934006 Imported vmailmgr-0.96.9
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    31
  if(chdir(user.home.c_str()) == -1) {
6f7a81934006 Imported vmailmgr-0.96.9
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    32
    ferr << cli_program << ": Can't change to home directory" << endl;
6f7a81934006 Imported vmailmgr-0.96.9
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    33
    return false;
6f7a81934006 Imported vmailmgr-0.96.9
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    34
  }
6f7a81934006 Imported vmailmgr-0.96.9
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    35
  config = &domain.config;
6f7a81934006 Imported vmailmgr-0.96.9
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    36
  password_file = config->password_file();
6f7a81934006 Imported vmailmgr-0.96.9
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    37
  return true;
6f7a81934006 Imported vmailmgr-0.96.9
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    38
}
6f7a81934006 Imported vmailmgr-0.96.9
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    39
6f7a81934006 Imported vmailmgr-0.96.9
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    40
pwentry user;
6f7a81934006 Imported vmailmgr-0.96.9
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    41
vdomain domain(user);
6f7a81934006 Imported vmailmgr-0.96.9
"Tomas Zeman <tzeman@volny.cz>"
parents:
diff changeset
    42
mystring password_file;