/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. #ifndef _HAVE_QSHELL_H
  27. #define _HAVE_QSHELL_H
  28. #include <netinet/in.h>
  29. #include <pwd.h>
  30. /*
  31. * Qshell argument structures
  32. * This structure contains the information that is gathered by
  33. * the implementation-specific ``getargs'' method passed in to
  34. * the qshell() function.
  35. *
  36. * Optional parameters should be set to NULL if they are not used.
  37. *
  38. */
  39. struct qshell_args {
  40. int sock; /* stderr socket */
  41. int port; /* stderror port */
  42. struct passwd * pwd; /* passwd entry for local user */
  43. char * hostname; /* Remote hostname */
  44. char * remuser; /* Remote username (optional) */
  45. char * locuser; /* Local username (optional) */
  46. char * cmdbuf; /* Remote command */
  47. };
  48. /*
  49. * Function prototype for implementation specific Qshell initialization.
  50. * This function is responsible for reading the qshell arguments from
  51. * the remote connection, as well as authentication of the remote user.
  52. *
  53. * On success, the `args' qshell_args struct should be filled in
  54. * with valid information.
  55. */
  56. typedef void (*QshGetArgsF)(struct sockaddr_in *, struct qshell_args *args);
  57. /*
  58. * Qshell implementation.
  59. * Initializes qshell connection using the argument count and vector
  60. * `ac' and `argv' respectively. The implementation-specific `getargs'
  61. * function is used to read arguments from the remote connection and
  62. * authorize and authenticate the user.
  63. *
  64. * The `name' parameter should be set to the name of the process
  65. * calling this function (used for error logging).
  66. *
  67. * If `check_port' is set to true, the connection will be terminated
  68. * if the originating port is not a reserved port.
  69. *
  70. */
  71. int qshell(int ac, char *argv[], QshGetArgsF getargs, char *name,
  72. int check_port);
  73. /*
  74. * Error reporting functions
  75. * These may only be called after the stderr connection is complete.
  76. */
  77. void error(const char *, ...);
  78. void errlog(const char *, ...);
  79. /*
  80. * Put a string of maximum length `len' into the destination `dst'
  81. * starting at memory location `src.'
  82. */
  83. int getstr(char *dst, int len, char *src);
  84. /*
  85. * Get passwd pointer for a username.
  86. */
  87. struct passwd *getpwnam_common(char *);
  88. /*
  89. * Determine canonical hostname given the sockaddr_in pointer
  90. */
  91. char *findhostname(struct sockaddr_in *);
  92. #ifdef USE_PAM
  93. int pamauth(struct passwd *, char *, char *, char *, char *);
  94. #endif
  95. #endif /* !_HAVE_QSHELL_H */