root/alternc/branches/larpoux-unstable/src/mail_add.c

Revision 6, 2.3 kB (checked in by anarcat, 3 years ago)

[project @ alternc: changeset 2003-03-27 00:42:15 by benjamin]
ajout des scripts shells d'AlternC

Original author: benjamin
Date: 2003-03-27 00:42:19

Line 
1 /*
2  $Id: mail_add.c,v 1.1 2003/03/27 00:42:19 benjamin Exp $
3  ----------------------------------------------------------------------
4  AlternC - Web Hosting System
5  Copyright (C) 2002 by the AlternC Development Team.
6  http://alternc.org/
7  ----------------------------------------------------------------------
8  Based on:
9  Valentin Lacambre's web hosting softwares: http://altern.org/
10  ----------------------------------------------------------------------
11  LICENSE
12
13  This program is free software; you can redistribute it and/or
14  modify it under the terms of the GNU General Public License (GPL)
15  as published by the Free Software Foundation; either version 2
16  of the License, or (at your option) any later version.
17
18  This program is distributed in the hope that it will be useful,
19  but WITHOUT ANY WARRANTY; without even the implied warranty of
20  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  GNU General Public License for more details.
22
23  To read the license please visit http://www.gnu.org/copyleft/gpl.html
24  ----------------------------------------------------------------------
25  Original Author of file: Benjamin Sonntag - 2002/02/01
26  Purpose of file: Creation d'un dossier email.
27  TODO: vérifier que seuls les caractères autorisés sont présents dans le mail.
28  ----------------------------------------------------------------------
29 */
30 #include <stdio.h>
31 #include <stdlib.h>
32
33
34
35 int main(int argc,char *argv[])
36 {
37         char mail[256],s[255];
38         unsigned int uid;
39
40   if (argc!=3)
41     {
42       printf("Utilisation : %s mailname uid\n  ",argv[0]);
43           printf("Cree la boite mail 'mailname' pour l'utilisateur 'uid'\n");
44       exit(-1);
45     }
46         strncpy(mail,argv[1],255);
47         mail[255]=0;
48         uid=atoi(argv[2]);
49         if (!uid)
50                 exit(-1);
51
52         setuid(geteuid());
53                 /*************************/
54                 /* WARNING : ROOT ZONE ! */
55                 /*************************/
56         sprintf(s,"/var/alternc/mail/%c/%s",mail[0],mail);
57         mkdir(s);
58         chown(s,33,uid);
59         chmod(s,02770);
60
61         sprintf(s,"/var/alternc/mail/%c/%s/Maildir",mail[0],mail);
62         mkdir(s);
63         chown(s,33,uid);
64         chmod(s,02770);
65
66         sprintf(s,"/var/alternc/mail/%c/%s/Maildir/cur",mail[0],mail);
67         mkdir(s);       
68         chown(s,33,uid);
69         chmod(s,02770);
70
71         sprintf(s,"/var/alternc/mail/%c/%s/Maildir/new",mail[0],mail);
72         mkdir(s);
73         chown(s,33,uid);
74         chmod(s,02770);
75
76         sprintf(s,"/var/alternc/mail/%c/%s/Maildir/tmp",mail[0],mail);
77         mkdir(s);
78         chown(s,33,uid);
79         chmod(s,02770);
80
81         exit(0);
82 }
83
Note: See TracBrowser for help on using the browser.