[3016] in Moira
Re: Incremental resetting the home directory in AD from DFS to
daemon@ATHENA.MIT.EDU (David Tanner)
Thu Jul 21 13:57:28 2005
Message-Id: <5.2.1.1.2.20050721135042.03e3bb30@hesiod>
Date: Thu, 21 Jul 2005 13:52:36 -0400
To: Garry Zacheiss <zacheiss@mit.edu>
From: David Tanner <dtanner@MIT.EDU>
Cc: moiradev@mit.edu, redelson@mit.edu
In-Reply-To: <200507211624.j6LGOm1M003998@brad-majors.mit.edu>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"; format=flowed
Ok, here are the changes you asked for. Let me know when I can test on ttsp.
David
Index: winad.c
===================================================================
RCS file:
\\afs\all\athena.mit.edu\astaff\project\moiradev\repository/moira/incremental/winad/winad.c,v
retrieving revision 1.45
diff -c -r1.45 winad.c
*** winad.c 2005/06/01 19:05:51 1.45
--- winad.c 2005/07/21 17:38:08
***************
*** 372,379 ****
int container_update(LDAP *ldap_handle, char *dn_path, int beforec, char
**before,
int afterc, char **after);
- int filesys_process(LDAP *ldap_handle, char *dn_path, char *fs_name,
- char *fs_type, char *fs_pack, int operation);
int GetAceInfo(int ac, char **av, void *ptr);
int GetServerList(char *ldap_domain, char **MasterServe);
int get_group_membership(char *group_membership, char *group_ou,
--- 372,377 ----
***************
*** 454,461 ****
void do_container(LDAP *ldap_handle, char *dn_path, char *ldap_hostname,
char **before, int beforec, char **after, int afterc);
- void do_filesys(LDAP *ldap_handle, char *dn_path, char *ldap_hostname,
- char **before, int beforec, char **after, int afterc);
void do_list(LDAP *ldap_handle, char *dn_path, char *ldap_hostname,
char **before, int beforec, char **after, int afterc);
void do_user(LDAP *ldap_handle, char *dn_path, char *ldap_hostname,
--- 452,457 ----
***************
*** 530,535 ****
--- 526,534 ----
before = &argv[4];
after = &argv[4 + beforec];
+ if (!strcmp(table, "filesys"))
+ exit(0);
+
if (afterc == 0)
after = NULL;
if (beforec == 0)
***************
*** 602,610 ****
else if (!strcmp(table, "imembers"))
do_member(ldap_handle, dn_path, ldap_domain, before, beforec, after,
afterc);
- else if (!strcmp(table, "filesys"))
- do_filesys(ldap_handle, dn_path, ldap_domain, before, beforec, after,
- afterc);
else if (!strcmp(table, "containers"))
do_container(ldap_handle, dn_path, ldap_domain, before, beforec, after,
afterc);
--- 601,606 ----
***************
*** 759,927 ****
return;
}
- void do_filesys(LDAP *ldap_handle, char *dn_path, char *ldap_hostname,
- char **before, int beforec, char **after, int afterc)
- {
- long rc;
- char *av[3];
- char *call_args[7];
- int acreate;
- int atype;
- int bcreate;
- int btype;
- int abort_flag;
-
- abort_flag = 0;
-
- if (afterc < FS_CREATE)
- atype = acreate = 0;
- else
- {
- atype = !strcmp(after[FS_TYPE], "AFS");
- acreate = atoi(after[FS_CREATE]);
- }
-
- if (beforec < FS_CREATE)
- {
- if (acreate == 0 || atype == 0)
- goto cleanup;
- com_err(whoami, 0, "Processing filesys %s", after[FS_NAME]);
- abort_flag = 0;
- while (1)
- {
- if ((rc = filesys_process(ldap_handle, dn_path, after[FS_NAME],
- after[FS_TYPE], after[FS_PACK], LDAP_MOD_ADD)) !=
LDAP_NO_SUCH_OBJECT)
- {
- if (rc != LDAP_SUCCESS)
- com_err(whoami, 0, "Unable to process filesys %s",
after[FS_NAME]);
- break;
- }
- if (abort_flag == 1)
- break;
- sleep(1);
- abort_flag = 1;
- if (rc = moira_connect())
- {
- critical_alert("AD incremental",
- "Error contacting Moira server : %s",
- error_message(rc));
- return;
- }
- av[0] = after[FS_NAME];
- call_args[0] = (char *)ldap_handle;
- call_args[1] = dn_path;
- call_args[2] = "";
- call_args[3] = NULL;
- sid_base = NULL;
- sid_ptr = &sid_base;
- callback_rc = 0;
- if (rc = mr_query("get_user_account_by_login", 1, av, user_create,
- call_args))
- {
- moira_disconnect();
- com_err(whoami, 0, "Unable to process filesys %s",
after[FS_NAME]);
- break;
- }
- if (callback_rc)
- {
- moira_disconnect();
- com_err(whoami, 0, "Unable to process filesys %s",
after[FS_NAME]);
- break;
- }
- if (sid_base != NULL)
- {
- sid_update(ldap_handle, dn_path);
- linklist_free(sid_base);
- sid_base = NULL;
- }
- moira_disconnect();
- }
- goto cleanup;
- }
-
- btype = !strcmp(before[FS_TYPE], "AFS");
- bcreate = atoi(before[FS_CREATE]);
- if (afterc < FS_CREATE)
- {
- if (btype && bcreate)
- {
- if (rc = filesys_process(ldap_handle, dn_path, before[FS_NAME],
- before[FS_TYPE], before[FS_PACK], LDAP_MOD_DELETE))
- {
- com_err(whoami, 0, "Unable to delete filesys %s",
before[FS_NAME]);
- }
- }
- return;
- }
-
- if (!acreate)
- return;
-
- if (!atype && !btype)
- {
- if (strcmp(before[FS_TYPE], "ERR") || strcmp(after[FS_TYPE], "ERR"))
- {
- com_err(whoami, 0, "Unable to process Filesystem %s or %s is
not AFS",
- before[FS_NAME], after[FS_NAME]);
- return;
- }
- }
- com_err(whoami, 0, "Processing filesys %s", after[FS_NAME]);
- abort_flag = 0;
- while (1)
- {
- if ((rc = filesys_process(ldap_handle, dn_path, after[FS_NAME],
- after[FS_TYPE], after[FS_PACK], LDAP_MOD_ADD)) !=
LDAP_NO_SUCH_OBJECT)
- {
- if (rc != LDAP_SUCCESS)
- com_err(whoami, 0, "Unable to process filesys %s", after[FS_NAME]);
- break;
- }
- if (abort_flag == 1)
- break;
- sleep(1);
- abort_flag = 1;
- if (rc = moira_connect())
- {
- critical_alert("AD incremental",
- "Error contacting Moira server : %s",
- error_message(rc));
- return;
- }
- av[0] = after[FS_NAME];
- call_args[0] = (char *)ldap_handle;
- call_args[1] = dn_path;
- call_args[2] = "";
- call_args[3] = NULL;
- sid_base = NULL;
- sid_ptr = &sid_base;
- callback_rc = 0;
- if (rc = mr_query("get_user_account_by_login", 1, av, user_create,
- call_args))
- {
- moira_disconnect();
- com_err(whoami, 0, "Unable to process filesys %s", after[FS_NAME]);
- break;
- }
- if (callback_rc)
- {
- moira_disconnect();
- com_err(whoami, 0, "Unable to process filesys %s", after[FS_NAME]);
- break;
- }
- if (sid_base != NULL)
- {
- sid_update(ldap_handle, dn_path);
- linklist_free(sid_base);
- sid_base = NULL;
- }
- moira_disconnect();
- }
-
- cleanup:
- return;
- }
-
#define L_LIST_DESC 9
#define L_LIST_ID 10
--- 755,760 ----
***************
*** 3110,3186 ****
for (i = 0; i < n; i++)
free(mods[i]);
return(rc);
- }
-
- int filesys_process(LDAP *ldap_handle, char *dn_path, char *fs_name,
- char *fs_type, char *fs_pack, int operation)
- {
- char distinguished_name[256];
- char winPath[256];
- char winProfile[256];
- char filter[128];
- char *attr_array[3];
- int group_count;
- int rc;
- LK_ENTRY *group_base;
-
- if (!check_string(fs_name))
- {
- com_err(whoami, 0, "Unable to process invalid filesys name %s",
fs_name);
- return(AD_INVALID_NAME);
- }
-
- if (strcmp(fs_type, "AFS"))
- {
- com_err(whoami, 0, "Unable to process invalid filesys type %s",
fs_type);
- return(AD_INVALID_FILESYS);
- }
-
- group_count = 0;
- group_base = NULL;
- sprintf(filter, "(sAMAccountName=%s)", fs_name);
- attr_array[0] = "cn";
- attr_array[1] = NULL;
- if ((rc = linklist_build(ldap_handle, dn_path, filter, attr_array,
- &group_base, &group_count,
LDAP_SCOPE_SUBTREE)) != 0)
- {
- com_err(whoami, 0, "Unable to process filesys %s : %s",
- fs_name, ldap_err2string(rc));
- return(rc);
- }
-
- if (group_count != 1)
- {
- linklist_free(group_base);
- com_err(whoami, 0, "Unable to find user %s in AD",
- fs_name);
- return(LDAP_NO_SUCH_OBJECT);
- }
- strcpy(distinguished_name, group_base->dn);
- linklist_free(group_base);
- group_count = 0;
-
- if (operation == LDAP_MOD_ADD)
- {
- memset(winPath, 0, sizeof(winPath));
- AfsToWinAfs(fs_pack, winPath);
- memset(winProfile, 0, sizeof(winProfile));
- strcpy(winProfile, winPath);
- strcat(winProfile, "\\.winprofile");
-
- rc = attribute_update(ldap_handle, distinguished_name, winProfile,
"profilePath", fs_name);
- rc = attribute_update(ldap_handle, distinguished_name, "H:",
"homeDrive", fs_name);
- rc = attribute_update(ldap_handle, distinguished_name, winPath,
"homeDirectory", fs_name);
-
- }
- else
- {
- rc = attribute_update(ldap_handle, distinguished_name, "",
"profilePath", fs_name);
- rc = attribute_update(ldap_handle, distinguished_name, "",
"homeDrive", fs_name);
- rc = attribute_update(ldap_handle, distinguished_name, "",
"homeDirectory", fs_name);
- }
-
- return(0);
}
int user_create(int ac, char **av, void *ptr)
--- 2943,2948 ----