├── CMakeLists.txt ├── COPYING ├── README.md ├── Uninstall.cmake ├── pam_groupnet.8 ├── pam_groupnet.c ├── pam_net_checkgroup.c ├── pam_net_checkgroup.h ├── pam_newnet.8 ├── pam_newnet.c ├── pam_usernet.8 └── pam_usernet.c /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 2 | project("libpam-net" 3 | VERSION 0.3 4 | DESCRIPTION "create/join network namespaces at login" 5 | HOMEPAGE_URL "https://github.com/rd235/libpam-net" 6 | LANGUAGES C) 7 | 8 | include(GNUInstallDirs) 9 | include(CheckIncludeFile) 10 | 11 | add_definitions(-D_GNU_SOURCE) 12 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}) 13 | 14 | unset(NLINLINE_INCLUDE CACHE) 15 | check_include_file(nlinline.h NLINLINE_INCLUDE) 16 | if(NOT NLINLINE_INCLUDE) 17 | message(FATAL_ERROR "*** required nlinline.h include file not found.\nInstall nlinline: https://github.com/virtualsquare/nlinline") 18 | endif() 19 | 20 | if(LIBSECURITYDIR) 21 | set(CMAKE_INSTALL_PAMDIR ${LIBSECURITYDIR}) 22 | else() 23 | set(CMAKE_INSTALL_PAMDIR ${CMAKE_INSTALL_LIBDIR}/security) 24 | endif() 25 | 26 | add_library(pam_newnet SHARED pam_newnet.c pam_net_checkgroup.c) 27 | set_target_properties(pam_newnet PROPERTIES PREFIX "") 28 | 29 | add_library(pam_usernet SHARED pam_usernet.c pam_net_checkgroup.c) 30 | set_target_properties(pam_usernet PROPERTIES PREFIX "") 31 | target_compile_definitions(pam_usernet PUBLIC PAM_USERNET) 32 | 33 | add_library(pam_groupnet SHARED pam_groupnet.c pam_net_checkgroup.c) 34 | set_target_properties(pam_groupnet PROPERTIES PREFIX "") 35 | target_compile_definitions(pam_groupnet PUBLIC PAM_GROUPNET) 36 | 37 | install(TARGETS pam_newnet pam_usernet pam_groupnet 38 | DESTINATION ${CMAKE_INSTALL_PAMDIR}) 39 | 40 | file(GLOB MAN8_PAGES ${CMAKE_CURRENT_SOURCE_DIR}/*.8) 41 | 42 | install(FILES ${MAN8_PAGES} 43 | DESTINATION ${CMAKE_INSTALL_MANDIR}/man8) 44 | 45 | add_custom_target(uninstall 46 | "${CMAKE_COMMAND}" 47 | -DCADO_SPOOL_DIR=${CADO_SPOOL_DIR} 48 | -P "${PROJECT_SOURCE_DIR}/Uninstall.cmake" 49 | ) 50 | 51 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc. 5 | 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Library General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | Appendix: How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 19yy 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) 19yy name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Library General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## LIBPAM-NET: create/join network namespaces at login 2 | 3 | **libpam-net** implements three pam modules: 4 | 5 | - **pam_newnet.so**: users belonging to the *newnet* group get a new 6 | network namespace at login 7 | 8 | - **pam_usernet.so** users belonging to the *usernet* group get their own 9 | network name at login. If a network namespace having the same name as the 10 | username exists, pam runs the user's shell in that namespace. If such a 11 | namespace does does not exist, it is created during the login process. 12 | 13 | - **pam_groupnet.so** users belonging to any group starting with *groupnet-* 14 | join the network namespace named after the dash of the group. 15 | If the specified network namespace exists, pam runs the user shell in that 16 | namespace. If such a namespace does does not exist, it is created during the 17 | login process. 18 | 19 | ### INSTALL: 20 | 21 | #### Requirements 22 | 23 | **libpam-net** needs [**nlinline**](https://github.com/virtualsquare/nlinline). 24 | 25 | #### Get the source code: 26 | ``` 27 | git clone https://github.com/rd235/libpam-net.git 28 | ``` 29 | #### Update the source code: 30 | ``` 31 | git pull 32 | ``` 33 | #### Compile and install 34 | Run the following commands from the root of the source tree: 35 | ``` 36 | mkdir build 37 | cd build 38 | cmake .. -DLIBSECURITYDIR=/lib/x86_64-linux-gnu/security/ 39 | make 40 | sudo make install 41 | ``` 42 | #### Configuration 43 | Add the rules to the pam configuration files: e.g. */etc/pam.d/sshd* or 44 | */etc/pam.d/login* 45 | ``` 46 | session required pam_newnet.so 47 | session required pam_usernet.so 48 | session required pam_groupnet.so 49 | ``` 50 | 51 | Create the groups *newnet*, *usernet* and any (or none) *groupnet-** 52 | including all the users that must be subject to one or the other service: 53 | 54 | e.g. in /etc/group: 55 | ``` 56 | newnet:x:149:renzononet 57 | usernet:x:150:renzousernet 58 | groupnet-vpn:x:151:renzogroupnet 59 | ``` 60 | 61 | ### Use Cases 62 | 63 | #### Disallowing external network access for selected users 64 | 65 | Using **pam_newnet.so** users in the *newnet* group can log-in through a network 66 | connection (e.g. by ssh) but their processes cannot communicate with the network 67 | at all. The only interface they can see is an isolated loopback **lo** interface 68 | created at login time. 69 | 70 | ##### Segregated network namespaces for selected user 71 | 72 | Using **pam_usernet.so** the system administrator can create network namespaces 73 | for each user in the *usernet* group. Each namespace must be named after each 74 | username. 75 | 76 | Alternatively, using **pam_groupnet.so** the system administrator can create 77 | different network namespaces to be shared by multiple users. e.g. for forced VPN 78 | tunneling without affecting other users. 79 | 80 | Users will *land* in their assigned network namespace at login. e.g. the 81 | sysadmin can create a network namespace for user *renzousernet* as follows: 82 | 83 | ``` 84 | # ip netns add renzousernet 85 | # ip -netns renzousernet link set dev lo up 86 | # ip -netns renzousernet tuntap add name eth0 mode tap 87 | # ... 88 | ``` 89 | 90 | If the directory `/etc/netns//` exists files directly underneath it are 91 | mounted over files in `/etc`. This can be used for overriding the DNS nameserver 92 | settings in the user's netns. 93 | 94 | Taking *renzousernet* as an example again, this is what you'd do: 95 | 96 | ``` 97 | # cat > /etc/netns/renzousernet/resolv.conf <. 19 | * 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | /* check if "user" belongs to "group" */ 28 | int checkgroup(const char *user, const char *group) { 29 | struct passwd *pw = getpwnam(user); 30 | struct group *gr = getgrnam(group); 31 | int ngroups=0; 32 | if (pw == NULL) return -1; 33 | if (gr == NULL) return 0; 34 | if (getgrouplist(user, pw->pw_gid, NULL, &ngroups) < 0) { 35 | gid_t gids[ngroups]; 36 | if (getgrouplist(user, pw->pw_gid, gids, &ngroups) == ngroups) { 37 | int i; 38 | for (i=0; igr_gid == gids[i]) 40 | return 1; 41 | } 42 | return 0; 43 | } 44 | } 45 | return -1; 46 | } 47 | 48 | char *get_groupnet_netns(const char *user, const char *group) { 49 | struct passwd *pw = getpwnam(user); 50 | int ngroups=0; 51 | 52 | if (pw == NULL || getgrouplist(user, pw->pw_gid, NULL, &ngroups) >= 0) { 53 | return NULL; 54 | } 55 | 56 | gid_t gids[ngroups]; 57 | if (getgrouplist(user, pw->pw_gid, gids, &ngroups) != ngroups) { 58 | return NULL; 59 | } 60 | 61 | int grouplen = strlen(group); 62 | int i; 63 | struct group *gr; 64 | for (i=0; igr_name, group, grouplen) == 0 67 | && strlen(gr->gr_name) > grouplen + 1 68 | && gr->gr_name[grouplen] == '-') { 69 | return strdup(gr->gr_name + grouplen + 1); 70 | } 71 | } 72 | 73 | return NULL; 74 | } 75 | -------------------------------------------------------------------------------- /pam_net_checkgroup.h: -------------------------------------------------------------------------------- 1 | #ifndef PAM_NET_COMMON_H 2 | #define PAM_NET_COMMON_H 3 | 4 | /* check if "user" belongs to "group" */ 5 | /* 0=NO 1=YES -1=error */ 6 | int checkgroup(const char *user, const char *group); 7 | 8 | /* get the name specified after a dash char '-' of "group" on a user. 9 | * if the user is part of multiple groups starting with "group", returns data from first matching group. */ 10 | /* NULL = not found/error. pointer must be freed. */ 11 | char *get_groupnet_netns(const char *user, const char *group); 12 | 13 | #endif //PAM_NET_COMMON_H 14 | -------------------------------------------------------------------------------- /pam_newnet.8: -------------------------------------------------------------------------------- 1 | .TH PAM_NEWNET 8 "October 5, 2019" "VirtualSquare Labs" 2 | .SH "NAME" 3 | pam_newnet \- create a new network namespace at login 4 | .SH "SYNOPSIS" 5 | \fBpam_newnet\&.so\fR 6 | 7 | .SH DESCRIPTION 8 | The pam_newnet PAM module creates a new network namespace at login for users in the 9 | \fInewnet\fR group. 10 | 11 | Users in the \fInewnet\fR group can log-in through a 12 | network connection (e.g. by ssh) but their processes cannot communicate. 13 | The only interface they can see is the localhost of the namespace created 14 | at login time. 15 | 16 | When pam_newnet is used together with a specific \fBcado(1)\fR configuration 17 | users can configure their own networking services. (see https://github.com/rd235/cado) 18 | 19 | The nsutils tools, and more specfically \fBnetnsjoin(1)\fR, allow users to 20 | assign placeholders to keep namespaces alive, assign meaningful tags for an easier management, 21 | and later join any of their own namespaces (see https://github.com/rd235/nsutils) 22 | 23 | .SH "OPTIONS" 24 | .PP 25 | \fBgroup=\fR\fB\fIgroupname\fR\fR 26 | .RS 4 27 | the module operates on users in the group \fIgroupname\fR instead of \fInewnet\fR. 28 | .RE 29 | .PP 30 | \fBlodown\fR 31 | .RS 4 32 | leave the localhost \fIlo\fR interface in the state DOWN. 33 | .RE 34 | 35 | .SH "RETURN VALUES" 36 | .PP 37 | PAM_IGNORE 38 | .RS 4 39 | User does not belong to the \fInewnet\fR group\&. 40 | .RE 41 | .PP 42 | PAM_ABORT 43 | .RS 4 44 | Error in retrieving the user id or in the namespace creation\&. 45 | .RE 46 | .PP 47 | PAM_SUCCESS 48 | .RS 4 49 | Success\&. 50 | .RE 51 | .SH "EXAMPLES" 52 | .PP 53 | Add the following lines to 54 | /etc/pam\&.d/sshd 55 | or /etc/pam\&.d/login 56 | .sp 57 | .RS 8 58 | session required pam_newnet.so 59 | .sp 60 | session required pam_newnet.so group=lonet lodown 61 | .RE 62 | .sp 63 | .SH "SEE ALSO" 64 | .PP 65 | \fBpam.conf\fR(5), 66 | \fBpam.d\fR(5), 67 | \fBpam\fR(7) 68 | .SH "AUTHOR" 69 | .PP 70 | pam_newnet was written by Renzo Davoli and Eduard Caizer, University of Bologna 71 | -------------------------------------------------------------------------------- /pam_newnet.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pam_newnet. 3 | * Copyright (C) 2016 Renzo Davoli, Eduard Caizer University of Bologna 4 | * 5 | * pam_newnet module 6 | * create a new network namespace at each login 7 | * (for users belonging to the "newnet" group) 8 | * 9 | * Cado is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 2 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; If not, see . 21 | * 22 | */ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #include 33 | #include 34 | 35 | #define DEFAULT_GROUP "newnet" 36 | 37 | /** 38 | * module args: 39 | * lodown, rootshared, group=.... 40 | */ 41 | struct pam_net_args { 42 | const char *group; 43 | int flags; 44 | }; 45 | #define LODOWN 0x1 46 | 47 | /** 48 | * parse_argv: parse module arguments 49 | */ 50 | static void parse_argv(struct pam_net_args *args, int argc, const char **argv) { 51 | for(; argc-- > 0; argv++) { 52 | if (strcmp(*argv, "lodown") == 0) 53 | args->flags |= LODOWN; 54 | else if (strncmp(*argv, "group=", 6) == 0) 55 | args->group = (*argv) + 6; 56 | else 57 | syslog (LOG_ERR, "Unknown option: %s", *argv); 58 | } 59 | } 60 | 61 | /** 62 | * init_log: log initialization with the given name 63 | */ 64 | void init_log(const char * log_name) 65 | { 66 | setlogmask (LOG_UPTO (LOG_NOTICE)); 67 | openlog (log_name, LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1); 68 | } 69 | 70 | /** 71 | * end_log: closes the log previously initialized 72 | */ 73 | void end_log() 74 | { 75 | closelog (); 76 | } 77 | 78 | /* 79 | * PAM entry point for session creation 80 | */ 81 | int pam_sm_open_session(pam_handle_t *pamh, int flags, int argc, const char **argv) 82 | { 83 | const char *user; 84 | int rv; 85 | int isnewnet; 86 | struct pam_net_args pam_args = { 87 | .group = DEFAULT_GROUP, 88 | .flags = 0}; 89 | 90 | init_log ("pam_newnet"); 91 | 92 | parse_argv(&pam_args, argc, argv); 93 | 94 | if ((rv=pam_get_user(pamh, &user, NULL) != PAM_SUCCESS)) { 95 | syslog (LOG_ERR, "get user: %s", strerror(errno)); 96 | goto close_log_and_exit; 97 | } 98 | 99 | isnewnet = checkgroup(user, pam_args.group); 100 | 101 | if (isnewnet > 0) { 102 | if (unshare(CLONE_NEWNET) < 0) { 103 | syslog (LOG_ERR, "Failed to create a new netns: %s", strerror(errno)); 104 | goto close_log_and_abort; 105 | } 106 | 107 | if ((pam_args.flags & LODOWN) == 0) 108 | nlinline_linksetupdown(1, 1); // bring lo up 109 | 110 | } else 111 | rv=PAM_IGNORE; 112 | close_log_and_exit: 113 | end_log(); 114 | return rv; 115 | close_log_and_abort: 116 | rv = PAM_ABORT; 117 | end_log(); 118 | return rv; 119 | } 120 | 121 | /* 122 | * PAM entry point for session cleanup 123 | */ 124 | int pam_sm_close_session(pam_handle_t *pamh, int flags, int argc, const char **argv) 125 | { 126 | return(PAM_IGNORE); 127 | } 128 | 129 | -------------------------------------------------------------------------------- /pam_usernet.8: -------------------------------------------------------------------------------- 1 | .TH PAM_USERNET 8 "August 17, 2016" "VirtualSquare Labs" 2 | .SH "NAME" 3 | pam_usernet \- join the user own network namespace at login 4 | .SH "SYNOPSIS" 5 | \fBpam_usernet\&.so\fR 6 | .SH DESCRIPTION 7 | The pam_usernet PAM module allow each user in \fIusernet\fR group to have their own 8 | network namespace. 9 | 10 | If a network namespace having the same name as the 11 | username exists, pam runs the user shell in that namespace. If such a 12 | namespace does does not exist, it is created during the login process. 13 | 14 | The system administrator can create a network 15 | namespace for each user in \fIusernet\fR group. Each namespace must be named 16 | after each username. 17 | Users will get their own network namespace at 18 | login. 19 | 20 | When pam_usernet is used together with a specific \fBcado(1)\fR configuration 21 | users can configure their own networking services. (see https://github.com/rd235/cado) 22 | 23 | .SH "OPTIONS" 24 | .PP 25 | \fBgroup=\fR\fB\fIgroupname\fR\fR 26 | .RS 4 27 | the module operates on users in the group \fIgroupname\fR instead of \fIusernet\fR. 28 | .RE 29 | .PP 30 | \fBlodown\fR 31 | .RS 4 32 | leave the localhost \fIlo\fR interface in the state DOWN. 33 | .RE 34 | .PP 35 | \fBrootshared\fR 36 | .RS 4 37 | Leave the root filesystem \fI/\fR as shared so mounts can propagate out to the 38 | parent namespace. Warning: this feature can create security vulnerabilities if not 39 | properly used. 40 | .RE 41 | 42 | .SH "RETURN VALUES" 43 | .PP 44 | PAM_IGNORE 45 | .RS 4 46 | User does not belong to the \fIusernet\fR group\&. 47 | .RE 48 | .PP 49 | PAM_ABORT 50 | .RS 4 51 | Error in retrieving the user id or in the namespace creation/joining\&. 52 | .RE 53 | .PP 54 | PAM_SUCCESS 55 | .RS 4 56 | Success\&. 57 | .RE 58 | .SH "EXAMPLES" 59 | .PP 60 | Add the following line to 61 | /etc/pam\&.d/sshd 62 | or /etc/pam\&.d/login 63 | .sp 64 | .RS 8 65 | session required pam_usernet.so 66 | .RE 67 | .sp 68 | .SH "SEE ALSO" 69 | .PP 70 | \fBpam.conf\fR(5), 71 | \fBpam.d\fR(5), 72 | \fBpam\fR(7) 73 | .SH "AUTHOR" 74 | .PP 75 | pam_usernet was written by Renzo Davoli and Eduard Caizer, University of Bologna 76 | -------------------------------------------------------------------------------- /pam_usernet.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pam_usernet / pam_groupnet (shared source) 3 | * Copyright (C) 2017-2024 Renzo Davoli University of Bologna 4 | * Copyright (C) 2018-2019 Daniel Gröber 5 | * Copyright (C) 2016 Renzo Davoli, Eduard Caizer University of Bologna 6 | * Copyright (C) 2011-2017 The iproute2 Authors 7 | * 8 | * pam_usernet module 9 | * provide each user with their own network 10 | * (for users belonging to the "usernet" group) 11 | * 12 | * pam_groupnet module 13 | * join users to a specific new or existing network, specified after the dash on the group name. 14 | * (for users belonging to the "groupnet-*" group) 15 | * 16 | * Cado is free software; you can redistribute it and/or 17 | * modify it under the terms of the GNU General Public License 18 | * as published by the Free Software Foundation; either version 2 19 | * of the License, or (at your option) any later version. 20 | * 21 | * This program is distributed in the hope that it will be useful, 22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 | * GNU General Public License for more details. 25 | * 26 | * You should have received a copy of the GNU General Public License 27 | * along with this program; If not, see . 28 | * 29 | */ 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | 48 | #include 49 | #include 50 | 51 | #ifdef PAM_USERNET 52 | #define DEFAULT_GROUP "usernet" 53 | #elif PAM_GROUPNET 54 | #define DEFAULT_GROUP "groupnet" 55 | #else 56 | #error either -DPAM_USERNET or -DPAM_GROUPNET must be defined 57 | #endif 58 | #define NETNS_RUN_DIR "/var/run/netns/" 59 | #define NETNS_ETC_DIR "/etc/netns" 60 | 61 | /** 62 | * module args: 63 | * lodown, rootshared, group=.... 64 | */ 65 | struct pam_net_args { 66 | const char *group; 67 | int flags; 68 | }; 69 | #define LODOWN 0x1 70 | #define ROOTSHARED 0x2 71 | 72 | /** 73 | * parse_argv: parse module arguments 74 | */ 75 | static void parse_argv(struct pam_net_args *args, int argc, const char **argv) { 76 | for(; argc-- > 0; argv++) { 77 | if (strcmp(*argv, "lodown") == 0) 78 | args->flags |= LODOWN; 79 | else if (strcmp(*argv, "rootshared") == 0) 80 | args->flags |= ROOTSHARED; 81 | else if (strncmp(*argv, "group=", 6) == 0) 82 | args->group = (*argv) + 6; 83 | else 84 | syslog (LOG_ERR, "Unknown option: %s", *argv); 85 | } 86 | } 87 | 88 | /** 89 | * init_log: log initialization with the given name 90 | */ 91 | void init_log(const char * log_name) 92 | { 93 | setlogmask (LOG_UPTO (LOG_NOTICE)); 94 | openlog (log_name, LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1); 95 | } 96 | 97 | /** 98 | * end_log: closes the log previously initialized 99 | */ 100 | void end_log() 101 | { 102 | closelog (); 103 | } 104 | 105 | /** 106 | * bind_etc: Mount config files from /etc/netns// into current namespace. 107 | */ 108 | int bind_etc(const char *name, int flags) 109 | { 110 | int rv = 0; 111 | char etc_netns_path[sizeof(NETNS_ETC_DIR) + NAME_MAX]; 112 | char netns_name[PATH_MAX]; 113 | char etc_name[PATH_MAX]; 114 | struct dirent *entry; 115 | DIR *dir; 116 | 117 | if (flags & ROOTSHARED) { 118 | /* ROOTSHARED */ 119 | 120 | /* Make /etc a mount point, so we can apply a propagation policy to it 121 | * below */ 122 | rv = mount("/etc", "/etc", "none", MS_BIND, NULL); 123 | if (rv == -1) { 124 | syslog (LOG_ERR, "mount --bind %s %s: %s", 125 | etc_netns_path, etc_netns_path, strerror(errno)); 126 | return -1; 127 | } 128 | 129 | /* Don't let bind mounts from /etc/netns// -> /etc/ 130 | * propagate back to the parent namespace */ 131 | if (mount("", "/etc", "none", MS_PRIVATE, NULL)) { 132 | syslog (LOG_ERR, "\"mount --make-private /%s\" failed: %s\n", 133 | etc_netns_path, strerror(errno)); 134 | return -1; 135 | } 136 | } 137 | 138 | snprintf(etc_netns_path, sizeof(etc_netns_path), "%s/%s", NETNS_ETC_DIR, name); 139 | dir = opendir(etc_netns_path); 140 | if (!dir) 141 | return errno == ENOENT ? 0 : -1; 142 | 143 | while ((entry = readdir(dir)) != NULL) { 144 | if (strcmp(entry->d_name, ".") == 0) 145 | continue; 146 | if (strcmp(entry->d_name, "..") == 0) 147 | continue; 148 | 149 | snprintf(netns_name, sizeof(netns_name), "%s/%s", etc_netns_path, entry->d_name); 150 | snprintf(etc_name, sizeof(etc_name), "/etc/%s", entry->d_name); 151 | if (mount(netns_name, etc_name, "none", MS_BIND, NULL) < 0) { 152 | syslog (LOG_ERR, "Bind %s -> %s failed: %s", 153 | netns_name, etc_name, strerror(errno)); 154 | } 155 | } 156 | 157 | closedir(dir); 158 | return 0; 159 | } 160 | 161 | /** 162 | * remount_sys: Mount a version of /sys that describes the new network namespace 163 | */ 164 | int remount_sys(const char *name, int flags) 165 | { 166 | unsigned long mountflags = MS_NOSUID | MS_NOEXEC | MS_NODEV; 167 | 168 | if ((flags & ROOTSHARED) == 0) { 169 | /* DEFAULT behavior: NOT ROOTSHARED */ 170 | /* Don't let any mounts propagate back to the parent */ 171 | if (mount("", "/", "none", MS_SLAVE | MS_REC, NULL)) { 172 | fprintf(stderr, "\"mount --make-rslave /\" failed: %s\n", 173 | strerror(errno)); 174 | return -1; 175 | } 176 | } else { 177 | /* ROOTSHARED */ 178 | /* Make /sys private so the remounting below doesn't 179 | * propagate to the parent namespace, since we're leaving 180 | * the root directory shared */ 181 | if (mount("", "/sys", "none", MS_PRIVATE | MS_REC, NULL)) { 182 | syslog (LOG_ERR, "\"mount --make-rprivate /sys\" failed: %s\n", 183 | strerror(errno)); 184 | return -1; 185 | } 186 | } 187 | 188 | /* Mount a version of /sys that describes the network namespace */ 189 | if (umount2("/sys", MNT_DETACH) < 0) { 190 | struct statvfs fsstat; 191 | 192 | /* If this fails, perhaps there wasn't a sysfs instance 193 | * mounted. Good. */ 194 | if (statvfs("/sys", &fsstat) == 0) { 195 | /* We couldn't umount the sysfs, we'll attempt to 196 | * overlay it. A read-only instance can't be shadowed 197 | * with a read-write one. */ 198 | if (fsstat.f_flag & ST_RDONLY) 199 | mountflags |= MS_RDONLY; 200 | } 201 | } 202 | 203 | if (mount(name, "/sys", "sysfs", mountflags, NULL) < 0) { 204 | syslog (LOG_ERR, "mount of /sys failed: %s", strerror(errno)); 205 | return -1; 206 | } 207 | 208 | if (mount("cgroup2", "/sys/fs/cgroup", "cgroup2", mountflags, NULL) < 0) { 209 | syslog (LOG_ERR, "mount of /sys/fs/cgroup failed: %s", strerror(errno)); 210 | return -1; 211 | } 212 | 213 | return 0; 214 | } 215 | 216 | /** 217 | * create_netns_rundir: Create /var/run/netns mount if it doesn't exist yet. 218 | */ 219 | int create_netns_rundir(void) 220 | { 221 | int rv = 0; 222 | 223 | rv = mkdir(NETNS_RUN_DIR, S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH); 224 | if (rv == -1 && errno != EEXIST) { 225 | syslog (LOG_ERR, "cannot create netns dir %s: %s", 226 | NETNS_RUN_DIR, strerror(errno)); 227 | return -1; 228 | } 229 | 230 | rv = mount("", NETNS_RUN_DIR, "none", MS_SHARED | MS_REC, NULL); 231 | if (rv == 0) { 232 | return 0; 233 | } 234 | 235 | if (errno != EINVAL) { 236 | syslog (LOG_ERR, "mount --make-shared %s: %s", 237 | NETNS_RUN_DIR, strerror(errno)); 238 | return -1; 239 | } 240 | 241 | rv = mount(NETNS_RUN_DIR, NETNS_RUN_DIR, "none", MS_BIND, NULL); 242 | if (rv == -1) { 243 | syslog (LOG_ERR, "mount --bind %s: %s", 244 | NETNS_RUN_DIR, strerror(errno)); 245 | return -1; 246 | } 247 | 248 | rv = mount("", NETNS_RUN_DIR, "none", MS_SHARED | MS_REC, NULL); 249 | if (rv == -1) { 250 | syslog (LOG_ERR, "mount --make-shared after bind %s: %s", 251 | NETNS_RUN_DIR, strerror(errno)); 252 | return -1; 253 | } 254 | 255 | return 0; 256 | } 257 | 258 | /** 259 | * unshare_netns: Create new netns, including mounting the handle to ns_path. 260 | */ 261 | int unshare_netns(char *ns_path, int flags) 262 | { 263 | int rv; 264 | int nsfd; 265 | 266 | nsfd = open(ns_path, O_RDONLY|O_CREAT|O_EXCL, 0); 267 | if (nsfd < 0) { 268 | syslog (LOG_ERR, "cannot create netns %s: %s", 269 | ns_path, strerror(errno)); 270 | return -1; 271 | } 272 | 273 | close(nsfd); 274 | 275 | rv = unshare(CLONE_NEWNET); 276 | if (rv < 0) { 277 | syslog (LOG_ERR, "Failed to create a new netns %s: %s", 278 | ns_path, strerror(errno)); 279 | return -1; 280 | } 281 | 282 | rv = mount("/proc/self/ns/net", ns_path, "none", MS_BIND, NULL); 283 | if (rv == -1) { 284 | syslog (LOG_ERR, "mount /proc/self/ns/net -> %s failed: %s", 285 | ns_path, strerror(errno)); 286 | return -1; 287 | } 288 | 289 | if ((flags & LODOWN) == 0) 290 | nlinline_linksetupdown(1, 1); // bring lo up 291 | 292 | return nsfd; 293 | } 294 | 295 | /** 296 | * enter_netns: Ensure we are in the netns referred to by ns_path, either by 297 | * creating it or entering it if it already exists. 298 | */ 299 | int enter_netns(char *ns_path, int flags) 300 | { 301 | int nsfd; 302 | nsfd = open(ns_path, O_RDONLY); 303 | if (nsfd < 0) { 304 | if (errno == ENOENT) { 305 | unshare_netns(ns_path, flags); 306 | } else { 307 | syslog (LOG_ERR, "netns open failed %s", ns_path); 308 | return -1; 309 | } 310 | } else { 311 | if (setns(nsfd, CLONE_NEWNET) != 0) { 312 | syslog (LOG_ERR, "cannot join netns %s: %s", 313 | ns_path, strerror(errno)); 314 | close(nsfd); 315 | return -1; 316 | } 317 | close(nsfd); 318 | } 319 | 320 | return 0; 321 | } 322 | 323 | /* 324 | * PAM entry point for session creation 325 | */ 326 | int pam_sm_open_session(pam_handle_t *pamh, int flags, int argc, const char **argv) 327 | { 328 | const char *user; 329 | int rv; 330 | char *target_netns = NULL; 331 | char ns_path[PATH_MAX]; 332 | struct pam_net_args pam_args = { 333 | .group = DEFAULT_GROUP, 334 | .flags = 0}; 335 | 336 | #ifdef PAM_USERNET 337 | init_log ("pam_usernet"); 338 | #elif PAM_GROUPNET 339 | init_log ("pam_groupnet"); 340 | #endif 341 | 342 | parse_argv(&pam_args, argc, argv); 343 | 344 | if ((rv=pam_get_user(pamh, &user, NULL) != PAM_SUCCESS)) { 345 | syslog (LOG_ERR, "get user: %s", strerror(errno)); 346 | end_log(); 347 | return PAM_SUCCESS; 348 | } 349 | 350 | #ifdef PAM_USERNET 351 | if (checkgroup(user, pam_args.group) > 0) 352 | target_netns = (char *) user; 353 | #elif PAM_GROUPNET 354 | target_netns = get_groupnet_netns(user, pam_args.group); 355 | #endif 356 | if(target_netns == NULL) { 357 | end_log(); 358 | return PAM_IGNORE; 359 | } 360 | 361 | if (create_netns_rundir() == -1) 362 | goto close_log_and_abort; 363 | 364 | snprintf(ns_path, sizeof(ns_path), "%s/%s", NETNS_RUN_DIR, target_netns); 365 | 366 | rv = enter_netns(ns_path, pam_args.flags); 367 | if(rv == -1) 368 | goto close_log_and_abort; 369 | 370 | if (unshare(CLONE_NEWNS) < 0) { 371 | syslog (LOG_ERR, "unshare(mount) failed: %s", strerror(errno)); 372 | goto close_log_and_abort; 373 | } 374 | 375 | if(remount_sys(target_netns, pam_args.flags) == -1) { 376 | syslog (LOG_ERR, "remounting /sys failed"); 377 | goto close_log_and_abort; 378 | } 379 | 380 | /* Setup bind mounts for config files in /etc */ 381 | if(bind_etc(target_netns, pam_args.flags) == -1) { 382 | syslog (LOG_ERR, "mounting /etc/netns/%s config files failed", 383 | target_netns); 384 | goto close_log_and_abort; 385 | } 386 | 387 | #ifdef PAM_GROUPNET 388 | free(target_netns); 389 | #endif 390 | end_log(); 391 | return PAM_SUCCESS; 392 | 393 | close_log_and_abort: 394 | #ifdef PAM_GROUPNET 395 | free(target_netns); 396 | #endif 397 | end_log(); 398 | return PAM_ABORT; 399 | } 400 | 401 | /* 402 | * PAM entry point for session cleanup 403 | */ 404 | int pam_sm_close_session(pam_handle_t *pamh, int flags, int argc, const char **argv) 405 | { 406 | return(PAM_IGNORE); 407 | } 408 | --------------------------------------------------------------------------------