📄 quipurc.c
字号:
/* message "search failed to find anything. */ }/* If the user does not exist in the DIT, print out the limited .quipurc * and the warning message, and allow the user to play DISH. */ if (search_result.CSR_entries == NULLENTRYINFO) { ps_printf(opt, "Unfortunately, you seem to have no entry in\n") ; ps_printf(opt, "the directory. Contact '%s' who should be able to help.\n", Manager) ; ps_printf(opt, "In the mean time, you can read, but not write.\n") ; } else { ptr = search_result.CSR_entries ; dn = dn_cpy(ptr->ent_dn) ; /* Essence of move user_name. */ /* collect the info and put it into current_entry */ /* Set up the desired attribute type to be read*/ /* from read.c */ if ((at = AttrT_new ("userPassword")) != NULLAttrT) { as_flag = as_merge (as_flag, as_comp_new (AttrT_cpy (at), NULLAV, NULLACL_INFO)); } else { ps_printf(rps, "Oops, Serious error. unknown attribute type 'userPassword'.\n") ; exit(1) ; } if ((current_entry = local_find_entry (dn, FALSE)) == NULLENTRY) { read_arg.rda_common = ca; /* struct copy */ read_arg.rda_object = dn; read_arg.rda_eis.eis_infotypes = EIS_ATTRIBUTESANDVALUES; read_arg.rda_eis.eis_allattributes = TRUE ; read_arg.rda_eis.eis_select = NULLATTR ; if (ds_read (&read_arg, &read_error, &read_result) != DS_OK) { ps_printf(rps, "We even seem to be having problems reading\n" ) ; ps_printf(rps, "an entry we searched and found!! HELP!!\n") ; exit(1) ; } if (read_result.rdr_entry.ent_attr == NULLATTR) { ps_printf(rps, "No attributes present. Even though\n") ; ps_printf(rps, "we found you by userid attribute!!! HELP!!\n") ; exit (1) ; } cache_entry (&(read_result.rdr_entry), read_arg.rda_eis.eis_allattributes, TRUE) ; } if ((current_entry = local_find_entry (dn, FALSE)) == NULLENTRY) { ps_printf(rps, "We still have nothing.Even after reading? Abort.\n") ; exit(1) ; } ps_printf(fileps, "username: ") ; dn_print(fileps, dn, EDBOUT) ; ps_printf(fileps, "\n") ; ps_printf(fileps, "me: ") ; dn_print(fileps, dn, EDBOUT) ; ps_printf(fileps, "\n") ; /* now showattribute -nokey to display it. */ ps_printf(fileps, "password: ") ; for (eptr = current_entry->e_attributes; eptr != NULLATTR; eptr = eptr->attr_link) { /* Tiptoe through the list of types until one matches, and then print value. */ if (AttrT_cmp (eptr->attr_type, at) == 0) { avs_print (fileps, eptr->attr_value,READOUT); break; } } if (eptr == NULLATTR) { while( strcmp(pass1, pass2)) { ps_printf(opt, "You need a password...\n") ; ps_printf(opt, "(do not use your UNIX system password)\n") ; (void) strcpy(pass1, getpassword("Enter Password: ")) ; (void) strcpy(pass2, getpassword("Re-enter password: ")) ; if (strcmp(pass1, pass2)) { ps_printf(opt, "\nMismatch - Try again.\n") ; } } ps_printf(fileps, "%s\n", pass1) ; um = umask(0177) ; if ((fp_draft = fopen(tmpdraft, "w")) == 0) { ps_print(rps, "Can't open draft file... Abort.\n") ; exit(1) ; } (void) umask(um) ; (void) fprintf(fp_draft, "UserPassword = %s\n", pass1) ; (void) fprintf(fp_draft, "acl = self # write # attributes # acl $ userPassword\n") ; (void) fprintf(fp_draft, "acl = others # compare # attributes # acl $ userPassword\n\n") ; (void) fclose(fp_draft) ; if ((fp_draft = fopen (tmpdraft, "r")) == NULL) { ps_printf (opt, "Can't open draft entry %s\n", tmpdraft); exit(1) ; } entry_ptr = get_default_entry (NULLENTRY);#ifdef TURBO_DISK entry_ptr->e_attributes = fget_attributes (fp_draft);#else entry_ptr->e_attributes = get_attributes (fp_draft);#endif (void) fclose (fp_draft); mod_arg.mea_common = ca; /* struct copy */ mod_arg.mea_object = dn; for (moddn = dn ; moddn->dn_parent != NULLDN; moddn=moddn->dn_parent) ; entry_ptr->e_name = rdn_cpy (moddn->dn_rdn); /* add rdn as attribute */ avst = avs_comp_new (AttrV_cpy (&entry_ptr->e_name->rdn_av)); temp = as_comp_new (AttrT_cpy (entry_ptr->e_name->rdn_at), avst, NULLACL_INFO); entry_ptr->e_attributes = as_merge (entry_ptr->e_attributes, temp); for (as = entry_ptr->e_attributes; as != NULLATTR; as = as->attr_link) { emnew = NULLMOD; trail = as->attr_link; as->attr_link = NULLATTR; temp = current_entry->e_attributes; for (; temp != NULLATTR; temp = temp->attr_link) if (AttrT_cmp (as->attr_type, temp->attr_type) == 0) { /* found it - does it need changing ? */ if (avs_cmp (as->attr_value, temp->attr_value) != 0) emnew = modify_avs (as->attr_value, temp->attr_value,as->attr_type); break; } if (temp == NULLATTR) { emnew = em_alloc (); emnew->em_type = EM_ADDATTRIBUTE; emnew->em_what = as_cpy(as); emnew->em_next = NULLMOD; } if (emnew != NULLMOD) { mod_arg.mea_changes = ems_append (mod_arg.mea_changes,emnew); } as->attr_link = trail; } while (ds_modifyentry (&mod_arg, &mod_error) != DS_OK) { if (dish_error (opt, &mod_error) == 0) { ps_printf(rps,"We have a dish error. Bye.\n") ; entry_free (entry_ptr); exit(1) ; } mod_arg.mea_object = mod_error.ERR_REFERRAL.DSE_ref_candidates->cr_name; } ps_print (rps, "Modified "); dn_print (rps, dn, EDBOUT); ps_print (rps, "\n"); delete_cache (dn); /* re-cache when next read */ entry_free (entry_ptr); ems_part_free (mod_arg.mea_changes); } } while(fgets(Read_in_Stuff, LINESIZE, fp_tailor) != 0) { (void) fputs(Read_in_Stuff, fp_quipurc) ; } (void) fclose(fp_quipurc) ; (void) fclose(fp_tailor) ;/* (void) fprintf(fp_quipurc, "dsap: local_dit \"%s\"\n", Local) ; (void) fprintf(fp_quipurc, "notype: acl\n") ; (void) fprintf(fp_quipurc, "notype: treestructure\n") ; (void) fprintf(fp_quipurc, "notype: masterdsa\n") ; (void) fprintf(fp_quipurc, "notype: slavedsa\n") ; (void) fprintf(fp_quipurc, "notype: objectclass\n") ; (void) fprintf(fp_quipurc, "cache_time: 30\n") ; (void) fprintf(fp_quipurc, "connect_time: 2\n") ; */ (void) ds_unbind() ; (void) unlink(tmpdraft) ; return(0);}voidadvise(){}voidset_sequence(){}voidunset_sequence(){}dish_error (ps,error)PS ps;struct DSError * error;{ if (error->dse_type == DSE_ABANDONED) { ps_printf (ps,"(DAP call interrupted - abandon successful)\n"); return (0); } if (error->dse_type == DSE_ABANDON_FAILED) { ps_printf (ps,"(DAP call interrupted - abandon unsuccessful)\n"); return (0); } if (error->dse_type == DSE_INTRERROR) { ps_printf (ps,"(DAP call interrupted)\n"); return (0); } ds_error (ps,error); return (0);}DN sequence_dn(y)int y;{struct dua_seq_entry * ptr;register int x = 1; if (current_sequence == NULL_DS) return (NULLDN); for (ptr=current_sequence->ds_data; (ptr != NULL_DE) && (x<y); ptr=ptr->de_next,x++) ; if (ptr == NULL_DE) return (NULLDN); if ( x == y ) return (ptr->de_name); return (NULLDN);}struct entrymod * ems_append (a,b)struct entrymod *a;struct entrymod *b;{struct entrymod *ptr; if ((ptr = a) == NULLMOD) return b; for ( ; ptr->em_next != NULLMOD; ptr = ptr->em_next) ; ptr->em_next = b; return a;}struct entrymod * modify_avs (a,b,ent_mod_at)AV_Sequence a;AV_Sequence b;AttributeType ent_mod_at;{AV_Sequence x;AV_Sequence y;struct entrymod *em = NULLMOD, *em_new;int removed_all = TRUE; for (x=b; x != NULLAV; x=x->avseq_next) { em_new = NULLMOD; for (y=a; y != NULLAV; y=y->avseq_next) if (AttrV_cmp (&x->avseq_av,&y->avseq_av) == 0) break; if (y == NULLAV) { em_new = em_alloc (); em_new->em_type = EM_REMOVEVALUES; em_new->em_what = as_comp_new (ent_mod_at,avs_comp_new(&x->avseq_av),NULLACL_INFO); em_new->em_next = NULLMOD; } else removed_all = FALSE; if (em_new != NULLMOD) em = ems_append (em,em_new); } if (removed_all) { ems_part_free (em); em_new = em_alloc (); em_new->em_type = EM_REMOVEATTRIBUTE; em_new->em_what = as_comp_new (ent_mod_at,b,NULLACL_INFO); em_new->em_next = em_alloc(); em_new->em_next->em_type = EM_ADDATTRIBUTE; em_new->em_next->em_what = as_comp_new (ent_mod_at,avs_cpy(a),NULLACL_INFO); em_new->em_next->em_next = NULLMOD; return (em_new); } for (x=a; x != NULLAV; x=x->avseq_next) { em_new = NULLMOD; for (y=b; y != NULLAV; y=y->avseq_next) if (AttrV_cmp (&x->avseq_av,&y->avseq_av) == 0) break; if (y == NULLAV) { em_new = em_alloc (); em_new->em_type = EM_ADDVALUES; em_new->em_what = as_comp_new (ent_mod_at,avs_comp_new(&x->avseq_av),NULLACL_INFO); em_new->em_next = NULLMOD; } if (em_new != NULLMOD) em = ems_append (em,em_new); } return (em);}ems_part_free(emp)struct entrymod *emp;{ if(emp == NULLMOD) return; ems_part_free(emp->em_next); free((char *)emp);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -