pam_listfile.8 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. '\" t
  2. .\" Title: pam_listfile
  3. .\" Author: [see the "AUTHOR" section]
  4. .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
  5. .\" Date: 09/03/2021
  6. .\" Manual: Linux-PAM Manual
  7. .\" Source: Linux-PAM Manual
  8. .\" Language: English
  9. .\"
  10. .TH "PAM_LISTFILE" "8" "09/03/2021" "Linux-PAM Manual" "Linux\-PAM Manual"
  11. .\" -----------------------------------------------------------------
  12. .\" * Define some portability stuff
  13. .\" -----------------------------------------------------------------
  14. .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  15. .\" http://bugs.debian.org/507673
  16. .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
  17. .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  18. .ie \n(.g .ds Aq \(aq
  19. .el .ds Aq '
  20. .\" -----------------------------------------------------------------
  21. .\" * set default formatting
  22. .\" -----------------------------------------------------------------
  23. .\" disable hyphenation
  24. .nh
  25. .\" disable justification (adjust text to left margin only)
  26. .ad l
  27. .\" -----------------------------------------------------------------
  28. .\" * MAIN CONTENT STARTS HERE *
  29. .\" -----------------------------------------------------------------
  30. .SH "NAME"
  31. pam_listfile \- deny or allow services based on an arbitrary file
  32. .SH "SYNOPSIS"
  33. .HP \w'\fBpam_listfile\&.so\fR\ 'u
  34. \fBpam_listfile\&.so\fR item=[tty|user|rhost|ruser|group|shell] sense=[allow|deny] file=\fI/path/filename\fR onerr=[succeed|fail] [apply=[\fIuser\fR|\fI@group\fR]] [quiet]
  35. .SH "DESCRIPTION"
  36. .PP
  37. pam_listfile is a PAM module which provides a way to deny or allow services based on an arbitrary file\&.
  38. .PP
  39. The module gets the
  40. \fBitem\fR
  41. of the type specified \-\-
  42. \fIuser\fR
  43. specifies the username,
  44. \fIPAM_USER\fR; tty specifies the name of the terminal over which the request has been made,
  45. \fIPAM_TTY\fR; rhost specifies the name of the remote host (if any) from which the request was made,
  46. \fIPAM_RHOST\fR; and ruser specifies the name of the remote user (if available) who made the request,
  47. \fIPAM_RUSER\fR
  48. \-\- and looks for an instance of that item in the
  49. \fBfile=\fR\fB\fIfilename\fR\fR\&.
  50. filename
  51. contains one line per item listed\&. If the item is found, then if
  52. \fBsense=\fR\fB\fIallow\fR\fR,
  53. \fIPAM_SUCCESS\fR
  54. is returned, causing the authorization request to succeed; else if
  55. \fBsense=\fR\fB\fIdeny\fR\fR,
  56. \fIPAM_AUTH_ERR\fR
  57. is returned, causing the authorization request to fail\&.
  58. .PP
  59. If an error is encountered (for instance, if
  60. filename
  61. does not exist, or a poorly\-constructed argument is encountered), then if
  62. \fIonerr=succeed\fR,
  63. \fIPAM_SUCCESS\fR
  64. is returned, otherwise if
  65. \fIonerr=fail\fR,
  66. \fIPAM_AUTH_ERR\fR
  67. or
  68. \fIPAM_SERVICE_ERR\fR
  69. (as appropriate) will be returned\&.
  70. .PP
  71. An additional argument,
  72. \fBapply=\fR, can be used to restrict the application of the above to a specific user (\fBapply=\fR\fB\fIusername\fR\fR) or a given group (\fBapply=\fR\fB\fI@groupname\fR\fR)\&. This added restriction is only meaningful when used with the
  73. \fItty\fR,
  74. \fIrhost\fR
  75. and
  76. \fIshell\fR
  77. items\&.
  78. .PP
  79. Besides this last one, all arguments should be specified; do not count on any default behavior\&.
  80. .PP
  81. No credentials are awarded by this module\&.
  82. .SH "OPTIONS"
  83. .PP
  84. .PP
  85. \fBitem=[tty|user|rhost|ruser|group|shell]\fR
  86. .RS 4
  87. What is listed in the file and should be checked for\&.
  88. .RE
  89. .PP
  90. \fBsense=[allow|deny]\fR
  91. .RS 4
  92. Action to take if found in file, if the item is NOT found in the file, then the opposite action is requested\&.
  93. .RE
  94. .PP
  95. \fBfile=\fR\fB\fI/path/filename\fR\fR
  96. .RS 4
  97. File containing one item per line\&. The file needs to be a plain file and not world writable\&.
  98. .RE
  99. .PP
  100. \fBonerr=[succeed|fail]\fR
  101. .RS 4
  102. What to do if something weird happens like being unable to open the file\&.
  103. .RE
  104. .PP
  105. \fBapply=[\fR\fB\fIuser\fR\fR\fB|\fR\fB\fI@group\fR\fR\fB]\fR
  106. .RS 4
  107. Restrict the user class for which the restriction apply\&. Note that with
  108. \fBitem=[user|ruser|group]\fR
  109. this does not make sense, but for
  110. \fBitem=[tty|rhost|shell]\fR
  111. it have a meaning\&.
  112. .RE
  113. .PP
  114. \fBquiet\fR
  115. .RS 4
  116. Do not treat service refusals or missing list files as errors that need to be logged\&.
  117. .RE
  118. .SH "MODULE TYPES PROVIDED"
  119. .PP
  120. All module types (\fBauth\fR,
  121. \fBaccount\fR,
  122. \fBpassword\fR
  123. and
  124. \fBsession\fR) are provided\&.
  125. .SH "RETURN VALUES"
  126. .PP
  127. .PP
  128. PAM_AUTH_ERR
  129. .RS 4
  130. Authentication failure\&.
  131. .RE
  132. .PP
  133. PAM_BUF_ERR
  134. .RS 4
  135. Memory buffer error\&.
  136. .RE
  137. .PP
  138. PAM_IGNORE
  139. .RS 4
  140. The rule does not apply to the
  141. \fBapply\fR
  142. option\&.
  143. .RE
  144. .PP
  145. PAM_SERVICE_ERR
  146. .RS 4
  147. Error in service module\&.
  148. .RE
  149. .PP
  150. PAM_SUCCESS
  151. .RS 4
  152. Success\&.
  153. .RE
  154. .SH "EXAMPLES"
  155. .PP
  156. Classic \*(Aqftpusers\*(Aq authentication can be implemented with this entry in
  157. /etc/pam\&.d/ftpd:
  158. .sp
  159. .if n \{\
  160. .RS 4
  161. .\}
  162. .nf
  163. #
  164. # deny ftp\-access to users listed in the /etc/ftpusers file
  165. #
  166. auth required pam_listfile\&.so \e
  167. onerr=succeed item=user sense=deny file=/etc/ftpusers
  168. .fi
  169. .if n \{\
  170. .RE
  171. .\}
  172. .sp
  173. Note, users listed in
  174. /etc/ftpusers
  175. file are (counterintuitively)
  176. \fInot\fR
  177. allowed access to the ftp service\&.
  178. .PP
  179. To allow login access only for certain users, you can use a
  180. /etc/pam\&.d/login
  181. entry like this:
  182. .sp
  183. .if n \{\
  184. .RS 4
  185. .\}
  186. .nf
  187. #
  188. # permit login to users listed in /etc/loginusers
  189. #
  190. auth required pam_listfile\&.so \e
  191. onerr=fail item=user sense=allow file=/etc/loginusers
  192. .fi
  193. .if n \{\
  194. .RE
  195. .\}
  196. .sp
  197. For this example to work, all users who are allowed to use the login service should be listed in the file
  198. /etc/loginusers\&. Unless you are explicitly trying to lock out root, make sure that when you do this, you leave a way for root to log in, either by listing root in
  199. /etc/loginusers, or by listing a user who is able to
  200. \fIsu\fR
  201. to the root account\&.
  202. .SH "SEE ALSO"
  203. .PP
  204. \fBpam.conf\fR(5),
  205. \fBpam.d\fR(5),
  206. \fBpam\fR(8)
  207. .SH "AUTHOR"
  208. .PP
  209. pam_listfile was written by Michael K\&. Johnson <johnsonm@redhat\&.com> and Elliot Lee <sopwith@cuc\&.edu>\&.