|
0
|
1 |
// Copyright (C) 1999,2000 Bruce Guenter <bruceg@em.ca>
|
|
|
2 |
//
|
|
|
3 |
// This program is free software; you can redistribute it and/or modify
|
|
|
4 |
// it under the terms of the GNU General Public License as published by
|
|
|
5 |
// the Free Software Foundation; either version 2 of the License, or
|
|
|
6 |
// (at your option) any later version.
|
|
|
7 |
//
|
|
|
8 |
// This program is distributed in the hope that it will be useful,
|
|
|
9 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
10 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
11 |
// GNU General Public License for more details.
|
|
|
12 |
//
|
|
|
13 |
// You should have received a copy of the GNU General Public License
|
|
|
14 |
// along with this program; if not, write to the Free Software
|
|
|
15 |
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
16 |
|
|
|
17 |
#include <config.h>
|
|
|
18 |
#include <stdlib.h>
|
|
|
19 |
#include <sys/stat.h>
|
|
|
20 |
#include "daemon.h"
|
|
|
21 |
|
|
|
22 |
CMD(chattr)
|
|
|
23 |
// Usage: chattr baseuser-virtuser pass attribute value [value ...]
|
|
|
24 |
{
|
|
|
25 |
mystring user = args[0];
|
|
|
26 |
mystring pass = args[1];
|
|
|
27 |
mystring attr = args[2];
|
|
|
28 |
mystring newval = args[3];
|
|
|
29 |
for(unsigned i = 4; i < args.count(); i++)
|
|
|
30 |
if(!!args[i])
|
|
|
31 |
newval = newval + string::NUL + args[i];
|
|
|
32 |
|
|
|
33 |
unsigned aval = strtoul(attr.c_str(), 0, 0);
|
|
|
34 |
bool userpass = false;
|
|
|
35 |
switch(aval) {
|
|
|
36 |
case vdomain::ATTR_PASS:
|
|
|
37 |
args[3] = LOG_NEWPASS;
|
|
|
38 |
userpass = true;
|
|
|
39 |
break;
|
|
|
40 |
case vdomain::ATTR_DEST:
|
|
|
41 |
case vdomain::ATTR_MAILBOX_ENABLED:
|
|
2
|
42 |
case vdomain::ATTR_PERSONAL:
|
|
0
|
43 |
userpass = true;
|
|
|
44 |
break;
|
|
|
45 |
}
|
|
|
46 |
args[1] = LOG_PASSWORD;
|
|
|
47 |
logcommand(args);
|
|
|
48 |
|
|
|
49 |
pwentry* pw;
|
|
|
50 |
vpwentry* vpw;
|
|
|
51 |
OK_RESPONSE(lookup_and_validate(user, pw, vpw, pass, true, userpass));
|
|
|
52 |
return state->domain.chattr(vpw, aval, newval);
|
|
|
53 |
}
|