[1947] in Moira
Kerberos-only accounts
daemon@ATHENA.MIT.EDU (Garry Zacheiss)
Mon Mar 25 19:13:38 2002
Message-Id: <200203260013.TAA01033@w20-spare-ultra5.mit.edu>
To: moiradev@MIT.EDU
Date: Mon, 25 Mar 2002 19:13:36 -0500
From: Garry Zacheiss <zacheiss@MIT.EDU>
This patch reverts the hack I put in the reg_svr for LINCOLN
accounts with preassigned usernames (Jeff wanted them created without
homedir or pobox) and implements a general facility for creating
accounts who only have Kerberos principals.
Most of the changes are in the reg_svr; the moirad change is so
that running register_user on a registered kerberos-only user turns them
into a full account, since it seemed nice to have an easy way of doing
that.
Garry
Index: include/moira_site.h
===================================================================
RCS file: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/include/moira_site.h,v
retrieving revision 1.44
diff -u -r1.44 moira_site.h
--- moira_site.h 2002/03/20 04:01:14 1.44
+++ moira_site.h 2002/03/26 00:10:18
@@ -379,15 +379,17 @@
/* User states (the value of argv[U_STATE] from a user query) */
-#define US_NO_LOGIN_YET 0
-#define US_REGISTERED 1
-#define US_NO_PASSWD 2
-#define US_DELETED 3
-#define US_NOT_ALLOWED 4
-#define US_ENROLLED 5
-#define US_ENROLL_NOT_ALLOWED 6
-#define US_HALF_ENROLLED 7
-#define US_END 8
+#define US_NO_LOGIN_YET 0
+#define US_REGISTERED 1
+#define US_NO_PASSWD 2
+#define US_DELETED 3
+#define US_NOT_ALLOWED 4
+#define US_ENROLLED 5
+#define US_ENROLL_NOT_ALLOWED 6
+#define US_HALF_ENROLLED 7
+#define US_NO_LOGIN_YET_KERBEROS_ONLY 8
+#define US_REGISTERED_KERBEROS_ONLY 9
+#define US_END 10
/* User shell queries */
Index: server/qsupport.pc
===================================================================
RCS file: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/server/qsupport.pc,v
retrieving revision 2.40
diff -u -r2.40 qsupport.pc
--- qsupport.pc 2001/12/14 21:05:35 2.40
+++ qsupport.pc 2002/03/25 22:35:58
@@ -1474,7 +1474,8 @@
/* find user */
EXEC SQL SELECT users_id, status INTO :users_id, :ostatus
FROM users
- WHERE unix_uid = :uid AND (status = 0 OR status = 5 OR status = 6);
+ WHERE unix_uid = :uid AND
+ (status = 0 OR status = 5 OR status = 6 OR status = 9);
if (sqlca.sqlerrd[2] == 0)
return MR_NO_MATCH;
@@ -1510,7 +1511,7 @@
WHERE label = :login || '.po';
if (dbms_errno)
return mr_errcode;
- if ((ostatus == 0) || (tmp != users_id))
+ if ((ostatus == 0 || ostatus == 9) || (tmp != users_id))
return MR_IN_USE;
else
po_exists = 1;
@@ -1657,7 +1658,7 @@
sprintf(buffer, "u.users_id = %d", users_id);
incremental_before(USERS_TABLE, buffer, 0);
nstatus = 2;
- if (ostatus == 5 || ostatus == 6)
+ if (ostatus == 5 || ostatus == 6 || ostatus == 9)
nstatus = 1;
EXEC SQL UPDATE users SET login = :login, status = :nstatus,
modtime = SYSDATE, modby = :who, modwith = :entity,
Index: reg_svr/reg_svr.h
===================================================================
RCS file: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/reg_svr/reg_svr.h,v
retrieving revision 1.14
diff -u -r1.14 reg_svr.h
--- reg_svr.h 2002/02/25 16:41:17 1.14
+++ reg_svr.h 2002/03/25 23:34:11
@@ -17,6 +17,7 @@
char *username; /* desired username. set by LOGN */
int reserved_username; /* if username wasn't picked by user */
unsigned short *random; /* random state */
+ int user_status; /* Status of account */
} reg_client;
void RIFO(reg_client *rc, int argc, char **argv);
Index: reg_svr/reg_svr.pc
===================================================================
RCS file: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/reg_svr/reg_svr.pc,v
retrieving revision 1.10
diff -u -r1.10 reg_svr.pc
--- reg_svr.pc 2002/02/25 16:41:17 1.10
+++ reg_svr.pc 2002/03/25 23:50:29
@@ -301,7 +301,7 @@
char middle[USERS_MIDDLE_SIZE], last[USERS_LAST_SIZE];
char fullname[USERS_FIRST_SIZE + USERS_MIDDLE_SIZE + USERS_LAST_SIZE];
char class[USERS_TYPE_SIZE], pin[USERS_PIN_SIZE];
- int uid, status, secure, sqlstatus, string_id;
+ int uid, status, secure, sqlstatus;
EXEC SQL END DECLARE SECTION;
if (rc->uid || argc != 4)
@@ -365,6 +365,7 @@
case US_REGISTERED:
case US_ENROLLED:
case US_ENROLL_NOT_ALLOWED:
+ case US_REGISTERED_KERBEROS_ONLY:
reply(rc, ALREADY_REGISTERED, "INIT", "c", NULL, login);
return;
@@ -380,6 +381,7 @@
break;
}
+ rc->user_status = status;
rc->uid = uid;
sprintf(fullname, "%s %s%s%s", first, middle, *middle ? " " : "", last);
if (!strcmp(class, "MITS"))
@@ -427,19 +429,13 @@
reply(rc, FOUND, "GETL", "c", rc->suggestions, fullname, class);
else
{
- if (status == US_NO_LOGIN_YET)
+ if (rc->user_status == US_NO_LOGIN_YET ||
+ rc->user_status == US_NO_LOGIN_YET_KERBEROS_ONLY)
{
status = check_kerberos(login);
- if (status == MR_SUCCESS)
- if (!strcmp(class, "LINCOLN"))
- {
- EXEC SQL SELECT string_id INTO :string_id FROM strings
- WHERE string = 'LINCOLN: no pobox or filesys';
- EXEC SQL UPDATE users SET comments = :string_id
- WHERE login = :login;
- }
- else
- status = register_user(rc->uid, login);
+ if (status == MR_SUCCESS &&
+ rc->user_status != US_NO_LOGIN_YET_KERBEROS_ONLY)
+ status = register_user(rc->uid, login);
if (status == MR_IN_USE)
{
reply(rc, RESERVED_USERNAME_UNAVAILABLE, "INIT", "c", NULL,
@@ -563,8 +559,12 @@
status = check_kerberos(login);
if (status == MR_SUCCESS)
- status = register_user(rc->uid, login);
-
+ {
+ if (rc->user_status == US_NO_LOGIN_YET_KERBEROS_ONLY)
+ EXEC SQL UPDATE users SET login = :login WHERE unix_uid = :rc->uid;
+ else
+ status = register_user(rc->uid, login);
+ }
if (status == MR_IN_USE)
{
if (rc->reserved_username)
@@ -679,7 +679,11 @@
reply(rc, KADM_ERROR, "INIT", "c", NULL, error_message(status));
return;
}
- EXEC SQL UPDATE users SET status = 1 WHERE login = :login;
+
+ if (rc->user_status == US_NO_LOGIN_YET_KERBEROS_ONLY)
+ EXEC SQL UPDATE users SET status = 9 WHERE login = :login;
+ else
+ EXEC SQL UPDATE users SET status = 1 WHERE login = :login;
EXEC SQL COMMIT;
reply(rc, DONE, "INIT", "c", NULL, rc->username);
Index: clients/moira/user.c
===================================================================
RCS file: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/clients/moira/user.c,v
retrieving revision 1.65
diff -u -r1.65 user.c
--- user.c 2001/10/17 21:34:19 1.65
+++ user.c 2002/03/25 20:48:40
@@ -62,7 +62,9 @@
"Not registerable (4)",
"Enrolled/Registerable (5)",
"Enrolled/Not Registerable (6)",
- "Half Enrolled (7)"
+ "Half Enrolled (7)",
+ "Registerable, Kerberos only (8)",
+ "Active, Kerberos only (9)"
};
static char *UserState(int state)
Index: clients/stanley/stanley.c
===================================================================
RCS file: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/clients/stanley/stanley.c,v
retrieving revision 1.7
diff -u -r1.7 stanley.c
--- stanley.c 2001/10/17 21:34:46 1.7
+++ stanley.c 2002/03/25 22:29:18
@@ -50,7 +50,9 @@
"Not registerable (4)",
"Enrolled/Registerable (5)",
"Enrolled/Not Registerable (6)",
- "Half Enrolled (7)"
+ "Half Enrolled (7)",
+ "Registerable, Kerberos only (8)",
+ "Active, Kerberos only (9)"
};
static char *UserState(int state)