PageRenderTime 20ms CodeModel.GetById 10ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/src/qsnet/qshell.h

https://code.google.com/
C++ Header | 109 lines | 25 code | 14 blank | 70 comment | 0 complexity | ac26e33b7128f4d566112f5fab407dc3 MD5 | raw file
  1/*****************************************************************************\
  2 *  $Id$
  3 *****************************************************************************
  4 *  Copyright (C) 2001-2006 The Regents of the University of California.
  5 *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  6 *  Written by Jim Garlick <garlick@llnl.gov>.
  7 *  UCRL-CODE-2003-005.
  8 *  
  9 *  This file is part of Pdsh, a parallel remote shell program.
 10 *  For details, see <http://www.llnl.gov/linux/pdsh/>.
 11 *  
 12 *  Pdsh is free software; you can redistribute it and/or modify it under
 13 *  the terms of the GNU General Public License as published by the Free
 14 *  Software Foundation; either version 2 of the License, or (at your option)
 15 *  any later version.
 16 *  
 17 *  Pdsh is distributed in the hope that it will be useful, but WITHOUT ANY
 18 *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 19 *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 20 *  details.
 21 *  
 22 *  You should have received a copy of the GNU General Public License along
 23 *  with Pdsh; if not, write to the Free Software Foundation, Inc.,
 24 *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
 25\*****************************************************************************/
 26
 27#ifndef _HAVE_QSHELL_H
 28#define _HAVE_QSHELL_H
 29
 30#include <netinet/in.h>
 31#include <pwd.h>
 32
 33/*
 34 *  Qshell argument structures
 35 *   This structure contains the information that is gathered by
 36 *   the implementation-specific ``getargs'' method passed in to
 37 *   the qshell() function. 
 38 *
 39 *   Optional parameters should be set to NULL if they are not used.
 40 *
 41 */
 42struct qshell_args {
 43    int               sock;       /* stderr socket                */ 
 44    int               port;       /* stderror port                */ 
 45    struct passwd *   pwd;        /* passwd entry for local user  */
 46    char *            hostname;   /* Remote hostname              */
 47    char *            remuser;    /* Remote username (optional)   */
 48    char *            locuser;    /* Local username  (optional)   */
 49    char *            cmdbuf;     /* Remote command               */
 50};
 51
 52
 53/*
 54 * Function prototype for implementation specific Qshell initialization.
 55 *   This function is responsible for reading the qshell arguments from
 56 *   the remote connection, as well as authentication of the remote user.
 57 *
 58 *   On success, the `args' qshell_args struct should be filled in
 59 *   with valid information.
 60 */
 61typedef void (*QshGetArgsF)(struct sockaddr_in *, struct qshell_args *args);  
 62
 63
 64/*
 65 *  Qshell implementation. 
 66 *    Initializes qshell connection using the argument count and vector
 67 *    `ac' and `argv' respectively. The implementation-specific `getargs' 
 68 *    function is used to read arguments from the remote connection and
 69 *    authorize and authenticate the user. 
 70 *
 71 *    The `name' parameter should be set to  the name of the process 
 72 *    calling this function (used for error logging). 
 73 *
 74 *    If `check_port' is set to true, the connection will be terminated 
 75 *    if the originating port is not a reserved port.
 76 *      
 77 */
 78int qshell(int ac, char *argv[], QshGetArgsF getargs, char *name, 
 79           int check_port);
 80
 81
 82/*  
 83 *  Error reporting functions 
 84 *   These may only be called after the stderr connection is complete.
 85 */
 86void error(const char *, ...);
 87void errlog(const char *, ...);
 88
 89/*
 90 *  Put a string of maximum length `len' into the destination `dst'
 91 *   starting at memory location `src.'
 92 */
 93int getstr(char *dst, int len, char *src);
 94
 95/*
 96 *  Get passwd pointer for a username.
 97 */
 98struct passwd *getpwnam_common(char *);
 99
100/*
101 *  Determine canonical hostname given the sockaddr_in pointer
102 */
103char *findhostname(struct sockaddr_in *);
104
105#ifdef USE_PAM
106int pamauth(struct passwd *, char *, char *, char *, char *);
107#endif
108
109#endif  /* !_HAVE_QSHELL_H */