]> andersk Git - moira.git/commitdiff
Allow users to run update_user_account, but only to change the
authorzacheiss <zacheiss>
Thu, 22 May 2003 17:03:55 +0000 (17:03 +0000)
committerzacheiss <zacheiss>
Thu, 22 May 2003 17:03:55 +0000 (17:03 +0000)
winhomedir and winprofiledir fields.

server/qaccess.pc

index c80e842609cb19a267e5e359fc1b42b0e5ac3226..bdceadf072378df500647e26a3749980978cbbd7 100644 (file)
@@ -41,7 +41,52 @@ int access_user(struct query *q, char *argv[], client *cl)
     return MR_SUCCESS;
 }
 
+int access_update_user(struct query *q, char *argv[], client *cl)
+{
+  EXEC SQL BEGIN DECLARE SECTION;
+  int users_id, unix_uid, status, comments, secure;
+  char login[USERS_LOGIN_SIZE], shell[USERS_SHELL_SIZE];
+  char winconsoleshell[USERS_WINCONSOLESHELL_SIZE], last[USERS_LAST_SIZE];
+  char first[USERS_FIRST_SIZE], middle[USERS_MIDDLE_SIZE];
+  char clearid[USERS_CLEARID_SIZE], type[USERS_TYPE_SIZE];
+  char signature[USERS_SIGNATURE_SIZE];
+  EXEC SQL END DECLARE SECTION;
 
+  /* The two fields we let users update themselves didn't appear until
+   * version 11.
+   */
+  if (q->version < 11)
+    return MR_PERM;
+
+  if (cl->users_id != *(int *)argv[0])
+    return MR_PERM;
+
+  users_id = *(int *)argv[0];
+
+  EXEC SQL SELECT u.login, u.unix_uid, u.shell, u.winconsoleshell, u.last,
+    u.first, u.middle, u.status, u.clearid, u.type, u.comments, u.signature,
+    u.secure INTO :login, :unix_uid, :shell, :winconsoleshell, :last, :first,
+    :middle, :status, :clearid, :type, :comments, :signature, :secure
+    FROM USERS u WHERE u.users_id = :users_id;
+
+  /* None of these things can have changed. */
+  if (strcmp(argv[1], strtrim(login)) ||
+      (unix_uid != atoi(argv[2])) ||
+      strcmp(argv[3], strtrim(shell)) ||
+      strcmp(argv[4], strtrim(winconsoleshell)) ||
+      strcmp(argv[5], strtrim(last)) ||
+      strcmp(argv[6], strtrim(first)) ||
+      strcmp(argv[7], strtrim(middle)) ||
+      (status != atoi(argv[8])) ||
+      strcmp(argv[9], strtrim(clearid)) ||
+      strcmp(argv[10], strtrim(type)) ||
+      (comments != *(int *)argv[11]) ||
+      strcmp(argv[12], strtrim(signature)) ||
+      (secure != atoi(argv[13])))
+    return MR_PERM;
+
+  return MR_SUCCESS;
+}
 
 /* access_login - verify that client name equals specified login name
  *
This page took 0.040936 seconds and 5 git commands to generate.