Readd quota support

This commit is contained in:
Michael Spang 2010-04-23 23:00:55 -04:00
parent 396140ef6b
commit 0e504612c8
4 changed files with 30 additions and 4 deletions

View File

@ -154,3 +154,18 @@ int ceo_create_home(char *homedir, char *skel, uid_t uid, gid_t gid, char *acces
return 0;
}
int ceo_set_quota(char *proto, int id) {
char user[128];
char *sqargs[] = { "setquota", "-a", "-p", proto, NULL, NULL };
snprintf(user, sizeof(user), "%d", id);
sqargs[4] = user;
if (spawnv("/usr/sbin/setquota", sqargs)) {
error("failed to set quota for %s", user);
return -1;
}
return 0;
}

View File

@ -3,3 +3,4 @@
#define CLUB_ACL "u::rwx,g::r-x,o::r-x,g:%d:rwx,m::rwx"
int ceo_create_home(char *homedir, char *skel, uid_t uid, gid_t gid, char *access_acl, char *default_acl, char *email);
int ceo_set_quota(char *proto, int id);

View File

@ -18,6 +18,7 @@ enum {
#define EKERB -2
#define ELDAP -3
#define EHOME -4
#define EQUOTA -5
int ceo_receive_message(int sock, struct strbuf *msg, uint32_t *msgtype);
int ceo_send_message(int sock, void *msg, size_t len, uint32_t msgtype);

View File

@ -139,7 +139,7 @@ static void adduser_spam(Ceo__AddUser *in, Ceo__AddUserResponse *out, char *clie
static int32_t addmember(Ceo__AddUser *in, Ceo__AddUserResponse *out) {
char homedir[1024];
char principal[1024];
int user_stat, group_stat, krb_stat, home_stat;
int user_stat, group_stat, krb_stat, home_stat, quota_stat;
int id;
if (snprintf(principal, sizeof(principal), "%s@%s",
@ -177,14 +177,18 @@ static int32_t addmember(Ceo__AddUser *in, Ceo__AddUserResponse *out) {
else
response_message(out, 0, "successfully created home directory");
if ((quota_stat = ceo_set_quota("ctdalek", id)))
response_message(out, EQUOTA, "unable to set quota for %s", in->username);
else
response_message(out, 0, "successfully set quota");
return krb_stat || user_stat || group_stat || home_stat;
return krb_stat || user_stat || group_stat || home_stat || quota_stat;
}
static int32_t addclub(Ceo__AddUser *in, Ceo__AddUserResponse *out) {
char homedir[1024];
char acl[64];
int krb_stat, user_stat, group_stat, sudo_stat, home_stat;
int krb_stat, user_stat, group_stat, sudo_stat, home_stat, quota_stat;
int id;
if (snprintf(homedir, sizeof(homedir), "%s/%s", club_home, in->username) >= sizeof(homedir))
@ -221,7 +225,12 @@ static int32_t addclub(Ceo__AddUser *in, Ceo__AddUserResponse *out) {
else
response_message(out, 0, "successfully created home directory");
return user_stat || group_stat || sudo_stat || home_stat;
if ((quota_stat = ceo_set_quota("csc", id)))
response_message(out, EQUOTA, "unable to set quota for %s", in->username);
else
response_message(out, 0, "successfully set quota");
return user_stat || group_stat || sudo_stat || home_stat || quota_stat;
}
static int32_t adduser(Ceo__AddUser *in, Ceo__AddUserResponse *out, char *client) {