1 //
2 //      aegis - project change supervisor
3 //      Copyright (C) 2007, 2008, 2011, 2012 Peter Miller
4 //
5 //      This program is free software; you can redistribute it and/or modify
6 //      it under the terms of the GNU General Public License as published by
7 //      the Free Software Foundation; either version 3 of the License, or
8 //      (at your option) any later version.
9 //
10 //      This program is distributed in the hope that it will be useful,
11 //      but WITHOUT ANY WARRANTY; without even the implied warranty of
12 //      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 //      GNU General Public License for more details.
14 //
15 //      You should have received a copy of the GNU General Public License
16 //      along with this program. If not, see
17 //      <http://www.gnu.org/licenses/>.
18 //
19 
20 #include <common/trace.h>
21 #include <libaegis/gonzo.h>
22 #include <libaegis/os.h>
23 #include <libaegis/project.h>
24 #include <libaegis/sub.h>
25 
26 
27 void
bind_keep(const nstring & home)28 project::bind_keep(const nstring &home)
29 {
30     trace(("project::bind_keep(home = %s)\n{\n", home.quote_c().c_str()));
31     if (gonzo_project_home_path_from_name(name_get()))
32     {
33         sub_context_ty sc;
34         sc.var_set_string("Name", name_get());
35         sc.fatal_intl(i18n("project $name exists"));
36         // NOTREACHED
37     }
38 
39     //
40     // we need to set the user *before* we set the home directory,
41     // because it goes into the directory and reads a few things.
42     //
43     up = user_ty::create();
44 
45     home_path_set(os_canonify_dirname(home));
46 
47     //
48     // Now set the group from the directory's permissions
49     //
50     get_the_owner();
51     if (uid != up->get_uid())
52     {
53         user_ty::pointer up1 = user_ty::create(uid);
54         sub_context_ty sc;
55         sc.var_set_string("FileName", home);
56         sc.var_set_string("Number1", up1->name());
57         sc.var_set_string("Number2", up->name());
58         sc.fatal_intl(i18n("$filename: owner is $number1, should be $number2"));
59         // NOTREACHED
60     }
61     up->set_gid(gid);
62     up->umask_set(umask_get());
63     trace(("}\n"));
64 }
65 
66 
67 // vim: set ts=8 sw=4 et :
68