Print this page
8485 Remove set but unused variables in usr/src/cmd


   6  * (the "License").  You may not use this file except in compliance
   7  * with the License.
   8  *
   9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10  * or http://www.opensolaris.org/os/licensing.
  11  * See the License for the specific language governing permissions
  12  * and limitations under the License.
  13  *
  14  * When distributing Covered Code, include this CDDL HEADER in each
  15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16  * If applicable, add the following below this CDDL HEADER, with the
  17  * fields enclosed by brackets "[]" replaced with your own identifying
  18  * information: Portions Copyright [yyyy] [name of copyright owner]
  19  *
  20  * CDDL HEADER END
  21  */
  22 /*
  23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  * Copyright 2012 Milan Jurik. All rights reserved.

  26  */
  27 
  28 #include <sys/types.h>
  29 #include <sys/errno.h>
  30 #include <sys/tiuser.h>
  31 #include <setjmp.h>
  32 
  33 #include <rpc/types.h>
  34 #include <rpc/xdr.h>
  35 #include <rpc/auth.h>
  36 #include <rpc/clnt.h>
  37 #include <rpc/rpc_msg.h>
  38 #include <rpc/rpcsec_gss.h>
  39 #include <string.h>
  40 #include "snoop.h"
  41 
  42 extern jmp_buf xdr_err;
  43 
  44 struct cache_struct *find_xid();
  45 char *nameof_prog(int prog);


 276                                 if (type == CALL) {
 277                                         print_rpc_gss_init_arg(flags, x);
 278                                 } else {
 279                                         print_rpc_gss_init_res(flags);
 280                                 }
 281                         }
 282                 }
 283                 return (1);
 284         }
 285 
 286         return (0);
 287 }
 288 
 289 /*
 290  *  Skip the header RPCSEC_GSS cred data and
 291  *  put service and control type in the xid cache.
 292  */
 293 void
 294 extract_rpcsec_gss_cred_info(int xid)
 295 {
 296         unsigned int seq_num;
 297         unsigned int handle_len;
 298         unsigned int flavor_len;
 299         unsigned int rpcsec_gss_ver;
 300         rpc_gss_service_t rpcsec_gss_service;
 301         unsigned int rpcsec_gss_proc;
 302         struct cache_struct *x;
 303 
 304         flavor_len = getxdr_u_long();
 305         rpcsec_gss_ver = getxdr_u_long();
 306         /* see if we know this version or not */
 307         if (rpcsec_gss_ver != 1) {
 308                 longjmp(xdr_err, 1);
 309         }
 310         rpcsec_gss_proc   = getxdr_u_long();
 311         seq_num    = getxdr_u_long();
 312         rpcsec_gss_service    = getxdr_enum();
 313         /* skip the handle */
 314         xdr_skip(RNDUP(getxdr_u_long()));
 315 
 316         if (x = find_xid(xid)) {
 317                 x->xid_gss_service = rpcsec_gss_service;
 318                 x->xid_gss_proc = rpcsec_gss_proc;
 319         }
 320 
 321 }
 322 
 323 /*
 324  *  Print the argument data for the RPCSEC_GSS_INIT control procedure.
 325  */
 326 static void
 327 print_rpc_gss_init_arg(int flags, struct cache_struct *x)
 328 {
 329 
 330         char *token, *line;
 331         unsigned int token_len;
 332         int pos = 0;
 333 
 334         /*
 335          *  see if we need to print out the rpc_gss_init_arg structure
 336          *  or not.
 337          */
 338 
 339         if (x->xid_gss_proc != RPCSEC_GSS_INIT &&
 340             x->xid_gss_proc != RPCSEC_GSS_CONTINUE_INIT) {
 341                 return;
 342         }
 343 
 344         /* print it */
 345 
 346         (void) sprintf(get_line(pos, getxdr_pos()),
 347             "RPCSEC_GSS_INIT args:");
 348 
 349         pos = getxdr_pos();
 350         token_len = getxdr_u_long();
 351         token = getxdr_hex(token_len);
 352         line = get_line(pos, getxdr_pos());
 353         sprintf(line, "   gss token: length = %d, data = [%d bytes]",
 354             token_len, token_len);
 355 
 356         show_trailer();
 357 }
 358 
 359 /*
 360  *  Print the results data for the RPCSEC_GSS_INIT control procedure.
 361  */
 362 void
 363 print_rpc_gss_init_res(int flags)
 364 {
 365 
 366         char *handle, *token, *line;
 367         unsigned int token_len, handle_len;
 368         unsigned int major, minor, seq_window;
 369 
 370         int pos = 0;
 371         struct cache_struct *x;
 372 
 373         /* print it */
 374 
 375         (void) sprintf(get_line(pos, getxdr_pos()), "RPCSEC_GSS_INIT result:");
 376 
 377         pos = getxdr_pos();
 378         handle_len = getxdr_u_long();
 379         handle = getxdr_hex(handle_len);
 380         line = get_line(pos, getxdr_pos());
 381         sprintf(line, "   handle: length = %d, data = [%s]",
 382             handle_len, handle);
 383         pos = getxdr_pos();
 384         major = getxdr_u_long();
 385         minor = getxdr_u_long();
 386         seq_window = getxdr_u_long();
 387 
 388         (void) sprintf(get_line(pos, getxdr_pos()),
 389             "   gss_major status = %u", major);
 390 
 391         (void) sprintf(get_line(pos, getxdr_pos()),
 392             "   gss_minor status = %u", minor);
 393 
 394         (void) sprintf(get_line(pos, getxdr_pos()),
 395             "   sequence window  = %u", seq_window);
 396         pos = getxdr_pos();
 397         token_len = getxdr_u_long();
 398         token = getxdr_hex(token_len);
 399         line = get_line(pos, getxdr_pos());
 400         sprintf(line, "   gss token: length = %d, data = [%d bytes]",
 401             token_len, token_len);
 402         show_trailer();
 403 }


   6  * (the "License").  You may not use this file except in compliance
   7  * with the License.
   8  *
   9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10  * or http://www.opensolaris.org/os/licensing.
  11  * See the License for the specific language governing permissions
  12  * and limitations under the License.
  13  *
  14  * When distributing Covered Code, include this CDDL HEADER in each
  15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16  * If applicable, add the following below this CDDL HEADER, with the
  17  * fields enclosed by brackets "[]" replaced with your own identifying
  18  * information: Portions Copyright [yyyy] [name of copyright owner]
  19  *
  20  * CDDL HEADER END
  21  */
  22 /*
  23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  * Copyright 2012 Milan Jurik. All rights reserved.
  26  * Copyright 2017 Gary Mills
  27  */
  28 
  29 #include <sys/types.h>
  30 #include <sys/errno.h>
  31 #include <sys/tiuser.h>
  32 #include <setjmp.h>
  33 
  34 #include <rpc/types.h>
  35 #include <rpc/xdr.h>
  36 #include <rpc/auth.h>
  37 #include <rpc/clnt.h>
  38 #include <rpc/rpc_msg.h>
  39 #include <rpc/rpcsec_gss.h>
  40 #include <string.h>
  41 #include "snoop.h"
  42 
  43 extern jmp_buf xdr_err;
  44 
  45 struct cache_struct *find_xid();
  46 char *nameof_prog(int prog);


 277                                 if (type == CALL) {
 278                                         print_rpc_gss_init_arg(flags, x);
 279                                 } else {
 280                                         print_rpc_gss_init_res(flags);
 281                                 }
 282                         }
 283                 }
 284                 return (1);
 285         }
 286 
 287         return (0);
 288 }
 289 
 290 /*
 291  *  Skip the header RPCSEC_GSS cred data and
 292  *  put service and control type in the xid cache.
 293  */
 294 void
 295 extract_rpcsec_gss_cred_info(int xid)
 296 {

 297         unsigned int handle_len;

 298         unsigned int rpcsec_gss_ver;
 299         rpc_gss_service_t rpcsec_gss_service;
 300         unsigned int rpcsec_gss_proc;
 301         struct cache_struct *x;
 302 
 303         (void) getxdr_u_long();
 304         rpcsec_gss_ver = getxdr_u_long();
 305         /* see if we know this version or not */
 306         if (rpcsec_gss_ver != 1) {
 307                 longjmp(xdr_err, 1);
 308         }
 309         rpcsec_gss_proc   = getxdr_u_long();
 310         (void) getxdr_u_long();
 311         rpcsec_gss_service    = getxdr_enum();
 312         /* skip the handle */
 313         xdr_skip(RNDUP(getxdr_u_long()));
 314 
 315         if (x = find_xid(xid)) {
 316                 x->xid_gss_service = rpcsec_gss_service;
 317                 x->xid_gss_proc = rpcsec_gss_proc;
 318         }
 319 
 320 }
 321 
 322 /*
 323  *  Print the argument data for the RPCSEC_GSS_INIT control procedure.
 324  */
 325 static void
 326 print_rpc_gss_init_arg(int flags, struct cache_struct *x)
 327 {
 328 
 329         char  *line;
 330         unsigned int token_len;
 331         int pos = 0;
 332 
 333         /*
 334          *  see if we need to print out the rpc_gss_init_arg structure
 335          *  or not.
 336          */
 337 
 338         if (x->xid_gss_proc != RPCSEC_GSS_INIT &&
 339             x->xid_gss_proc != RPCSEC_GSS_CONTINUE_INIT) {
 340                 return;
 341         }
 342 
 343         /* print it */
 344 
 345         (void) sprintf(get_line(pos, getxdr_pos()),
 346             "RPCSEC_GSS_INIT args:");
 347 
 348         pos = getxdr_pos();
 349         token_len = getxdr_u_long();
 350         (void) getxdr_hex(token_len);
 351         line = get_line(pos, getxdr_pos());
 352         sprintf(line, "   gss token: length = %d, data = [%d bytes]",
 353             token_len, token_len);
 354 
 355         show_trailer();
 356 }
 357 
 358 /*
 359  *  Print the results data for the RPCSEC_GSS_INIT control procedure.
 360  */
 361 void
 362 print_rpc_gss_init_res(int flags)
 363 {
 364 
 365         char *handle, *line;
 366         unsigned int token_len, handle_len;
 367         unsigned int major, minor, seq_window;
 368 
 369         int pos = 0;
 370         struct cache_struct *x;
 371 
 372         /* print it */
 373 
 374         (void) sprintf(get_line(pos, getxdr_pos()), "RPCSEC_GSS_INIT result:");
 375 
 376         pos = getxdr_pos();
 377         handle_len = getxdr_u_long();
 378         handle = getxdr_hex(handle_len);
 379         line = get_line(pos, getxdr_pos());
 380         sprintf(line, "   handle: length = %d, data = [%s]",
 381             handle_len, handle);
 382         pos = getxdr_pos();
 383         major = getxdr_u_long();
 384         minor = getxdr_u_long();
 385         seq_window = getxdr_u_long();
 386 
 387         (void) sprintf(get_line(pos, getxdr_pos()),
 388             "   gss_major status = %u", major);
 389 
 390         (void) sprintf(get_line(pos, getxdr_pos()),
 391             "   gss_minor status = %u", minor);
 392 
 393         (void) sprintf(get_line(pos, getxdr_pos()),
 394             "   sequence window  = %u", seq_window);
 395         pos = getxdr_pos();
 396         token_len = getxdr_u_long();
 397         (void) getxdr_hex(token_len);
 398         line = get_line(pos, getxdr_pos());
 399         sprintf(line, "   gss token: length = %d, data = [%d bytes]",
 400             token_len, token_len);
 401         show_trailer();
 402 }