* authorization.c, heuristic.c, krb_auth_su.c, main.c, setenv.c:
authorEzra Peisach <epeisach@mit.edu>
Tue, 5 Jun 2001 16:53:24 +0000 (16:53 +0000)
committerEzra Peisach <epeisach@mit.edu>
Tue, 5 Jun 2001 16:53:24 +0000 (16:53 +0000)
Cleanup assignments in conditionals.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@13272 dc483132-0cff-0310-8789-dd5450dbe970

src/clients/ksu/ChangeLog
src/clients/ksu/authorization.c
src/clients/ksu/heuristic.c
src/clients/ksu/krb_auth_su.c
src/clients/ksu/main.c
src/clients/ksu/setenv.c

index 0772244a1d37aa56c456293c5789405ff07f0a06..f2dc459d97d4df2fe393bf125ab910900f061830 100644 (file)
@@ -1,3 +1,8 @@
+2001-06-05  Ezra Peisach  <epeisach@mit.edu>
+
+       * authorization.c, heuristic.c, krb_auth_su.c, main.c, setenv.c:
+       Cleanup assignments in conditionals.
+
 2001-04-03  Tom Yu  <tlyu@mit.edu>
 
        * setenv.c: Add conditionals for compilation of setenv, unsetenv,
index a2e540936dab4b03f556c2406fa0c945a13b3dcb..6d98a78b97c8ead81b8a2bac7093e57f2be471bd 100644 (file)
@@ -86,7 +86,8 @@ krb5_error_code krb5_authorization(context, principal, luser,
     if ((pwd = getpwnam(luser)) == NULL)
        return 0;
 
-    if (retval = krb5_unparse_name(context, principal, &princname))
+    retval = krb5_unparse_name(context, principal, &princname);
+    if (retval)
        return retval;
 
 #ifdef DEBUG
@@ -146,7 +147,9 @@ krb5_error_code krb5_authorization(context, principal, luser,
            fprintf(stderr,
                    "In krb5_authorization: principal to be authorized %s\n",
                    princname);
-       if (retval = k5login_lookup( login_fp,  princname, &retbool)){
+
+       retval = k5login_lookup(login_fp,  princname, &retbool);
+       if (retval) {
            auth_cleanup(users_fp, login_fp, princname);
            return retval;
        }
@@ -157,8 +160,9 @@ krb5_error_code krb5_authorization(context, principal, luser,
     }
 
     if ((!k5users_flag) && (retbool == FALSE) ){
-       if(retval = k5users_lookup (users_fp, princname,
-                                   cmd, &retbool, out_fcmd)){
+       retval = k5users_lookup (users_fp, princname,
+                                cmd, &retbool, out_fcmd);
+       if(retval) {
            auth_cleanup(users_fp, login_fp, princname);
            return retval;
        }
@@ -201,10 +205,9 @@ krb5_error_code k5login_lookup (fp, princname, found)
     char * lp;
     krb5_boolean loc_found = FALSE;
 
-
-    if (retval = get_line(fp, &line )){
+    retval = get_line(fp, &line);
+    if (retval)
        return retval;
-    }
 
     while (line){
        fprinc = get_first_token (line, &lp);
@@ -222,7 +225,10 @@ krb5_error_code k5login_lookup (fp, princname, found)
        }
 
        free (line);
-       if (retval = get_line(fp, &line )){ return retval;}
+
+       retval = get_line(fp, &line);
+       if (retval)
+           return retval;
     }
 
 
@@ -263,7 +269,8 @@ krb5_error_code k5users_lookup (fp, princname, cmd, found, out_fcmd)
     char * loc_fcmd = NULL;
     krb5_boolean loc_found = FALSE;
 
-    if (retval = get_line(fp, &line ))
+    retval = get_line(fp, &line);
+    if (retval)
        return retval;
 
     while (line){
@@ -307,7 +314,7 @@ krb5_error_code k5users_lookup (fp, princname, cmd, found, out_fcmd)
                            }
                        }
 
-                   }while (fcmd = get_next_token( &lp));
+                   }while ((fcmd = get_next_token( &lp)));
                }
                free (line);
                break;
@@ -315,7 +322,11 @@ krb5_error_code k5users_lookup (fp, princname, cmd, found, out_fcmd)
        }
 
        free (line);
-       if (retval = get_line(fp, &line )){ return retval;}
+
+       retval = get_line(fp, &line);
+       if (retval) { 
+           return retval;
+       }
     }
 
     *out_fcmd = loc_fcmd;
@@ -397,7 +408,7 @@ krb5_boolean fcmd_resolve(fcmd, out_fcmd, out_err)
 
            i++;
 
-       } while(tc = get_next_token (&lp));
+       } while((tc = get_next_token (&lp)));
 
        tmp_fcmd[i] = NULL;
        *out_fcmd = tmp_fcmd;
@@ -589,7 +600,8 @@ krb5_error_code get_line (fp, out_line)
     line[0] = '\0';
 
     while (( r = fgets(line_ptr, BUFSIZ , fp)) != NULL){
-       if (newline = strchr(line_ptr, '\n')){
+       newline = strchr(line_ptr, '\n');
+       if (newline) {
            *newline = '\0';
            break;
        }
index f941ea97d0849b8fb053523f0947eb00aabb52b7..76d6977446f7ab6891f72c0fdcd4dbc0240709e9 100644 (file)
@@ -52,7 +52,8 @@ krb5_error_code get_all_princ_from_file (fp, plist)
     if (!(temp_list = (char **) malloc( CHUNK * sizeof(char *))))
        return errno;
 
-    if (retval = get_line(fp, &line ))
+    retval = get_line(fp, &line);
+    if (retval)
        return retval;  
 
     while (line){
@@ -73,7 +74,9 @@ krb5_error_code get_all_princ_from_file (fp, plist)
 
 
        free (line);
-       if (retval = get_line(fp, &line )){ return retval;}
+       retval = get_line(fp, &line);
+       if (retval)
+           return retval;
     }
 
     temp_list[count] = NULL;
@@ -158,7 +161,8 @@ filter(fp, cmd, k5users_list, k5users_filt_list)
 
     while(k5users_list[i]){    
 
-       if (retval= k5users_lookup(fp, k5users_list[i], cmd, &found, &out_cmd))
+       retval= k5users_lookup(fp, k5users_list[i], cmd, &found, &out_cmd);
+       if (retval)
            return retval;
 
        if (found == FALSE){            
@@ -233,21 +237,24 @@ get_authorized_princ_names(luser, cmd, princ_list)
            return 0;
         }
 
-       if(retval = get_all_princ_from_file (users_fp, &k5users_list)){
+       retval = get_all_princ_from_file (users_fp, &k5users_list);
+       if(retval) {
            close_time(k5users_flag,users_fp, k5login_flag,login_fp);
            return retval;
        }
 
        rewind(users_fp);       
        
-       if(retval = filter(users_fp,cmd, k5users_list, &k5users_filt_list)){
+       retval = filter(users_fp,cmd, k5users_list, &k5users_filt_list);
+       if(retval) {
            close_time(k5users_flag,users_fp, k5login_flag, login_fp);
            return retval;
        }
     }
        
     if (!k5login_flag){
-       if(retval = get_all_princ_from_file (login_fp, &k5login_list)){
+       retval = get_all_princ_from_file (login_fp, &k5login_list);
+       if(retval) {
            close_time(k5users_flag,users_fp, k5login_flag,login_fp);
            return retval;
        }
@@ -256,13 +263,13 @@ get_authorized_princ_names(luser, cmd, princ_list)
     close_time(k5users_flag,users_fp, k5login_flag, login_fp);
 
     if (cmd) {
-       if (retval = list_union(k5login_list,
-                              k5users_filt_list, &combined_list)){
-           close_time(k5users_flag,users_fp, k5login_flag,login_fp);
-           return retval;
-       }
-       *princ_list = combined_list;
-       return 0;
+      retval = list_union(k5login_list, k5users_filt_list, &combined_list);
+      if (retval){
+         close_time(k5users_flag,users_fp, k5login_flag,login_fp);
+         return retval;
+      }
+      *princ_list = combined_list;
+      return 0;
     } else {
        if (k5users_filt_list != NULL)
            free(k5users_filt_list);
@@ -332,29 +339,30 @@ krb5_error_code get_closest_principal(context, plist, client, found)
 
     while(plist[i]){
 
-       if (retval = krb5_parse_name(context, plist[i], &temp_client))
+       retval = krb5_parse_name(context, plist[i], &temp_client);
+       if (retval)
            return retval;
-
+       
        pnelem = krb5_princ_size(context, temp_client);
-
+       
        if ( cnelem > pnelem){  
            i++;
            continue;
        }
-
+       
        if (krb5_princ_realm(context, *client)->length ==
            krb5_princ_realm(context, temp_client)->length
            && (!memcmp (krb5_princ_realm(context, *client)->data,
                         krb5_princ_realm(context, temp_client)->data,
                         krb5_princ_realm(context, temp_client)->length))){
-
+           
            got_one = TRUE;
            for(j =0; j < cnelem; j ++){
                krb5_data *p1 =
                    krb5_princ_component(context, *client, j);
                krb5_data *p2 =
                    krb5_princ_component(context, temp_client, j);
-
+               
                if ((p1->length != p2->length) ||
                    memcmp(p1->data,p2->data,p1->length)){
                    got_one = FALSE;
@@ -373,7 +381,7 @@ krb5_error_code get_closest_principal(context, plist, client, found)
        }
        i++;
     }
-
+    
     if (best_client) {
        *found = TRUE;
        *client = best_client;
@@ -405,18 +413,20 @@ krb5_error_code find_either_ticket (context, cc, client, end_server, found)
 
     if ( ! stat(cc_source_name, &st_temp)){
 
-       if (retval = find_ticket(context, cc, client, end_server, &temp_found))
+       retval = find_ticket(context, cc, client, end_server, &temp_found);
+       if (retval)
            return retval;
        
        if (temp_found == FALSE){
-           if (retval = krb5_tgtname(context,
-                                     krb5_princ_realm(context, client),
-                                     krb5_princ_realm(context, client),
-                                     &kdc_server)){
-               return retval ;
-           }
+           retval = krb5_tgtname(context,
+                                 krb5_princ_realm(context, client),
+                                 krb5_princ_realm(context, client),
+                                 &kdc_server);
+           if (retval)
+               return retval;
 
-           if(retval = find_ticket(context, cc,client, kdc_server, &temp_found))
+           retval = find_ticket(context, cc,client, kdc_server, &temp_found);
+           if(retval)
                return retval;
        }
        else if (auth_debug)
@@ -445,10 +455,12 @@ krb5_error_code find_ticket (context, cc, client, server, found)
     memset((char *) &tgtq, 0, sizeof(tgtq));
     memset((char *) &tgt, 0, sizeof(tgt));
 
-    if (retval= krb5_copy_principal(context,  client, &tgtq.client))
+    retval= krb5_copy_principal(context,  client, &tgtq.client);
+    if (retval)
        return retval;  
 
-    if (retval= krb5_copy_principal(context,  server, &tgtq.server))
+    retval= krb5_copy_principal(context,  server, &tgtq.server);
+    if (retval)
        return retval ;         
 
     retval = krb5_cc_retrieve_cred(context, cc, KRB5_TC_MATCH_SRV_NAMEONLY | KRB5_TC_SUPPORTED_KTYPES,
@@ -489,7 +501,8 @@ krb5_error_code find_princ_in_list (context, princ, plist, found)
 
     if (!plist) return 0;
 
-    if (retval = krb5_unparse_name(context, princ, &princname))
+    retval = krb5_unparse_name(context, princ, &princname);
+    if (retval)
        return retval;
 
     while (plist[i] ){
@@ -558,14 +571,18 @@ krb5_error_code get_best_princ_for_target(context, source_uid, target_uid,
     cc_source_name = krb5_cc_get_name(context, cc_source);
 
        
-    if (! stat(cc_source_name, &st_temp))
-       if (retval = krb5_cc_get_principal(context, cc_source, &cc_def_princ))
+    if (! stat(cc_source_name, &st_temp)) {
+       retval = krb5_cc_get_principal(context, cc_source, &cc_def_princ);
+       if (retval)
            return retval;
+    }
 
-       
-    if (retval=krb5_parse_name(context, target_user, &target_client))
+    retval=krb5_parse_name(context, target_user, &target_client);
+    if (retval)
        return retval;
-    if (retval=krb5_parse_name(context, source_user, &source_client))
+
+    retval=krb5_parse_name(context, source_user, &source_client);
+    if (retval)
        return retval;
 
     if (source_uid == 0){
@@ -614,7 +631,8 @@ krb5_error_code get_best_princ_for_target(context, source_uid, target_uid,
 
        return 0;       
     }else{
-       if (retval = get_authorized_princ_names(target_user, cmd, &aplist))
+       retval = get_authorized_princ_names(target_user, cmd, &aplist);
+       if (retval)
            return retval;
 
        /* .k5users or .k5login exist, but no authorization */
@@ -626,8 +644,9 @@ krb5_error_code get_best_princ_for_target(context, source_uid, target_uid,
        }
     }
 
-    if (retval = krb5_sname_to_principal(context, hostname, NULL,
-                                        KRB5_NT_SRV_HST, &end_server))
+    retval = krb5_sname_to_principal(context, hostname, NULL,
+                                    KRB5_NT_SRV_HST, &end_server);
+    if (retval)
        return retval;
 
 
@@ -649,15 +668,18 @@ krb5_error_code get_best_princ_for_target(context, source_uid, target_uid,
 
     for (i= 0; i < count; i ++){
        if(princ_trials[i].p) { 
-           if (retval= find_princ_in_list(context, princ_trials[i].p, aplist, &found))
+           retval= find_princ_in_list(context, princ_trials[i].p, aplist, 
+                                      &found);
+           if (retval)
                return retval;  
        
            if (found == TRUE){
                princ_trials[i].found = TRUE;
 
-               if (retval = find_either_ticket (context, cc_source,
-                                                princ_trials[i].p,
-                                                end_server, &found))
+               retval = find_either_ticket (context, cc_source, 
+                                            princ_trials[i].p,
+                                            end_server, &found);
+               if (retval)
                    return retval;
                if (found == TRUE){
                    *client = princ_trials[i].p;
@@ -674,12 +696,13 @@ krb5_error_code get_best_princ_for_target(context, source_uid, target_uid,
 
     i=0;
     while (aplist[i]){
-
-       if (retval = krb5_parse_name(context, aplist[i], &temp_client))
+       retval = krb5_parse_name(context, aplist[i], &temp_client);
+       if (retval)
            return retval;
 
-       if (retval = find_either_ticket (context, cc_source, temp_client,
-                                        end_server, &found))
+       retval = find_either_ticket (context, cc_source, temp_client,
+                                    end_server, &found);
+       if (retval)
            return retval;
 
        if (found == TRUE){
@@ -711,14 +734,17 @@ krb5_error_code get_best_princ_for_target(context, source_uid, target_uid,
 #ifdef PRINC_LOOK_AHEAD
     for (i=0; i < count; i ++){
        if (princ_trials[i].p){
-           if(retval=krb5_copy_principal(context, princ_trials[i].p,
-                                         &temp_client))
+           retval=krb5_copy_principal(context, princ_trials[i].p,
+                                      &temp_client);
+           if(retval)
                return retval;  
 
            /* get the client name that is the closest
               to the three princ in trials */
 
-           if(retval=get_closest_principal(context, aplist, &temp_client, & found))
+           retval=get_closest_principal(context, aplist, &temp_client, 
+                                        &found);
+           if(retval)
                return retval;  
 
            if (found == TRUE){
index cfb27032073faf23ce9ba2ce37d64651a222d98a..4e6bf127b5c16d2f57b5c8079a28da5ad415189e 100644 (file)
@@ -344,7 +344,8 @@ krb5_keyblock *     tkt_ses_key;
        }
 
        /* Check to make sure ticket hasn't expired */
-       if (retval = krb5_check_exp(context, tkt->enc_part2->times)) {
+       retval = krb5_check_exp(context, tkt->enc_part2->times);
+       if (retval) {
                if (auth_debug && (retval == KRB5KRB_AP_ERR_TKT_EXPIRED)) {
                        fprintf(stderr,
                                "krb5_verify_tkt_def: ticket has expired");
index 9e28c0d6f6b348ff9b4e76c2d2e723f2b6044a23..17b33cdca6281b618a3221f5311511a28381e3ef 100644 (file)
@@ -116,7 +116,6 @@ krb5_boolean stored = FALSE;
 krb5_principal  kdc_server;
 krb5_boolean zero_password;
 char * dir_of_cc_target;     
-char * dir_of_cc_source; 
 
     options.opt = KRB5_DEFAULT_OPTIONS;
     options.lifetime = KRB5_DEFAULT_TKT_LIFE;
@@ -799,7 +798,7 @@ krb5_seteuid(0); /*So we have some chance of sweeping up*/
        default:
            if (auth_debug){
                printf(" The child pid is %ld\n", (long) child_pid);
-               printf(" The parent pid is %d\n", getpid());
+               printf(" The parent pid is %ld\n", (long) getpid());
            }
             while ((ret_pid = waitpid(child_pid, &statusp, WUNTRACED)) != -1) {
                if (WIFSTOPPED(statusp)) {
index 2633a9d11589fd14e7e598c15128c700c573db3f..173a2ba5f06434315e826576ff260900cdced4de 100644 (file)
@@ -26,6 +26,7 @@
  *     "value".  If rewrite is set, replace any current value.
  */
 #ifndef HAVE_SETENV
+int
 setenv(name, value, rewrite)
        register char *name, *value;
        int rewrite;
@@ -43,7 +44,7 @@ setenv(name, value, rewrite)
                if (!rewrite)
                        return(0);
                if (strlen(C) >= l_value) {     /* old larger; copy over */
-                       while (*C++ = *value++);
+                       while ((*C++ = *value++));
                        return(0);
                }
        }