1 From b62415943878891ce000b9e0b414354b60047876 Mon Sep 17 00:00:00 2001
2 From: babak sarashki <babak.sarashki@windriver.com>
3 Date: Tue, 2 Jul 2019 14:09:28 -0700
4 Subject: [PATCH 1/2] cgcs-users with patch ibsh patches
6 Applied ibsh-0.3e-cgcs.patch and copyright patch.
8 base/cgcs-users/cgcs-users-1.0/BUGS | 19 +
9 base/cgcs-users/cgcs-users-1.0/CONTRIBUTORS | 7 +
10 base/cgcs-users/cgcs-users-1.0/COPYING | 340 ++++++++++++++++++
11 base/cgcs-users/cgcs-users-1.0/COPYRIGHT | 17 +
12 base/cgcs-users/cgcs-users-1.0/INSTALL | 23 ++
13 base/cgcs-users/cgcs-users-1.0/Makefile | 56 +++
14 base/cgcs-users/cgcs-users-1.0/README | 29 ++
15 base/cgcs-users/cgcs-users-1.0/Release | 17 +
16 base/cgcs-users/cgcs-users-1.0/TODO | 10 +
17 base/cgcs-users/cgcs-users-1.0/VERSION | 1 +
18 base/cgcs-users/cgcs-users-1.0/antixploit.c | 131 +++++++
19 base/cgcs-users/cgcs-users-1.0/command.c | 209 +++++++++++
20 base/cgcs-users/cgcs-users-1.0/config.c | 179 +++++++++
21 base/cgcs-users/cgcs-users-1.0/delbadfiles.c | 239 ++++++++++++
22 .../cgcs-users-1.0/example.allowall.xtns | 28 ++
23 .../cgcs-users-1.0/example.denyall.xtns | 2 +
24 base/cgcs-users/cgcs-users-1.0/execute.c | 159 ++++++++
25 base/cgcs-users/cgcs-users-1.0/globals.cmds | 8 +
26 base/cgcs-users/cgcs-users-1.0/globals.xtns | 3 +
27 base/cgcs-users/cgcs-users-1.0/ibsh.h | 126 +++++++
28 base/cgcs-users/cgcs-users-1.0/jail.c | 101 ++++++
29 base/cgcs-users/cgcs-users-1.0/main.c | 239 ++++++++++++
30 base/cgcs-users/cgcs-users-1.0/misc.c | 52 +++
31 23 files changed, 1995 insertions(+)
32 create mode 100644 base/cgcs-users/cgcs-users-1.0/BUGS
33 create mode 100644 base/cgcs-users/cgcs-users-1.0/CONTRIBUTORS
34 create mode 100644 base/cgcs-users/cgcs-users-1.0/COPYING
35 create mode 100644 base/cgcs-users/cgcs-users-1.0/COPYRIGHT
36 create mode 100644 base/cgcs-users/cgcs-users-1.0/INSTALL
37 create mode 100644 base/cgcs-users/cgcs-users-1.0/Makefile
38 create mode 100644 base/cgcs-users/cgcs-users-1.0/README
39 create mode 100644 base/cgcs-users/cgcs-users-1.0/Release
40 create mode 100644 base/cgcs-users/cgcs-users-1.0/TODO
41 create mode 100644 base/cgcs-users/cgcs-users-1.0/VERSION
42 create mode 100644 base/cgcs-users/cgcs-users-1.0/antixploit.c
43 create mode 100644 base/cgcs-users/cgcs-users-1.0/command.c
44 create mode 100644 base/cgcs-users/cgcs-users-1.0/config.c
45 create mode 100644 base/cgcs-users/cgcs-users-1.0/delbadfiles.c
46 create mode 100644 base/cgcs-users/cgcs-users-1.0/example.allowall.xtns
47 create mode 100644 base/cgcs-users/cgcs-users-1.0/example.denyall.xtns
48 create mode 100644 base/cgcs-users/cgcs-users-1.0/execute.c
49 create mode 100644 base/cgcs-users/cgcs-users-1.0/globals.cmds
50 create mode 100644 base/cgcs-users/cgcs-users-1.0/globals.xtns
51 create mode 100644 base/cgcs-users/cgcs-users-1.0/ibsh.h
52 create mode 100644 base/cgcs-users/cgcs-users-1.0/jail.c
53 create mode 100644 base/cgcs-users/cgcs-users-1.0/main.c
54 create mode 100644 base/cgcs-users/cgcs-users-1.0/misc.c
56 diff --git a/base/cgcs-users/cgcs-users-1.0/BUGS b/base/cgcs-users/cgcs-users-1.0/BUGS
58 index 0000000..7dacaab
60 +++ b/base/cgcs-users/cgcs-users-1.0/BUGS
66 +- Input length checking on all inputs, string copies, etc. is fixed.
67 +- The myscanf function will no longer accept more then 80 chars at once,
68 +so ibsh hopefully wont crash on a too long input.
69 +- Added signal.h in the header file, the lack of it caused compilation
70 +problems on some systems.
71 +- Fixed the infinite loop in DelBadFiles. This function is temporarily
72 +taken out of the project
73 +- Removed the involvment of /bin/sh from system. Added path checking.
74 +- In jail root, not only ../ is not allowed, but .. too.
75 +- Fixed a bug, that happened on bsd, when the user pressed ^D.
76 +- Fixed a bug with opendir
77 +- Fixed a format string vulnerability in logprintbadfile(). Thanks to
78 +Kim Streich for the report.
81 diff --git a/base/cgcs-users/cgcs-users-1.0/CONTRIBUTORS b/base/cgcs-users/cgcs-users-1.0/CONTRIBUTORS
83 index 0000000..35ca436
85 +++ b/base/cgcs-users/cgcs-users-1.0/CONTRIBUTORS
87 +CONTRIBUTORS TO PROJECT IBSH
89 +Kim Streich <kstreich at gmail.com>
90 + * bug finder, debugger, tester.
92 +RazoR (Nikolay Alexandrov) <Nikolay@Alexandrov.ws>
93 + * bug finder, debugger, tester.
94 diff --git a/base/cgcs-users/cgcs-users-1.0/COPYING b/base/cgcs-users/cgcs-users-1.0/COPYING
96 index 0000000..d60c31a
98 +++ b/base/cgcs-users/cgcs-users-1.0/COPYING
100 + GNU GENERAL PUBLIC LICENSE
101 + Version 2, June 1991
103 + Copyright (C) 1989, 1991 Free Software Foundation, Inc.
104 + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
105 + Everyone is permitted to copy and distribute verbatim copies
106 + of this license document, but changing it is not allowed.
110 + The licenses for most software are designed to take away your
111 +freedom to share and change it. By contrast, the GNU General Public
112 +License is intended to guarantee your freedom to share and change free
113 +software--to make sure the software is free for all its users. This
114 +General Public License applies to most of the Free Software
115 +Foundation's software and to any other program whose authors commit to
116 +using it. (Some other Free Software Foundation software is covered by
117 +the GNU Library General Public License instead.) You can apply it to
120 + When we speak of free software, we are referring to freedom, not
121 +price. Our General Public Licenses are designed to make sure that you
122 +have the freedom to distribute copies of free software (and charge for
123 +this service if you wish), that you receive source code or can get it
124 +if you want it, that you can change the software or use pieces of it
125 +in new free programs; and that you know you can do these things.
127 + To protect your rights, we need to make restrictions that forbid
128 +anyone to deny you these rights or to ask you to surrender the rights.
129 +These restrictions translate to certain responsibilities for you if you
130 +distribute copies of the software, or if you modify it.
132 + For example, if you distribute copies of such a program, whether
133 +gratis or for a fee, you must give the recipients all the rights that
134 +you have. You must make sure that they, too, receive or can get the
135 +source code. And you must show them these terms so they know their
138 + We protect your rights with two steps: (1) copyright the software, and
139 +(2) offer you this license which gives you legal permission to copy,
140 +distribute and/or modify the software.
142 + Also, for each author's protection and ours, we want to make certain
143 +that everyone understands that there is no warranty for this free
144 +software. If the software is modified by someone else and passed on, we
145 +want its recipients to know that what they have is not the original, so
146 +that any problems introduced by others will not reflect on the original
147 +authors' reputations.
149 + Finally, any free program is threatened constantly by software
150 +patents. We wish to avoid the danger that redistributors of a free
151 +program will individually obtain patent licenses, in effect making the
152 +program proprietary. To prevent this, we have made it clear that any
153 +patent must be licensed for everyone's free use or not licensed at all.
155 + The precise terms and conditions for copying, distribution and
156 +modification follow.
158 + GNU GENERAL PUBLIC LICENSE
159 + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
161 + 0. This License applies to any program or other work which contains
162 +a notice placed by the copyright holder saying it may be distributed
163 +under the terms of this General Public License. The "Program", below,
164 +refers to any such program or work, and a "work based on the Program"
165 +means either the Program or any derivative work under copyright law:
166 +that is to say, a work containing the Program or a portion of it,
167 +either verbatim or with modifications and/or translated into another
168 +language. (Hereinafter, translation is included without limitation in
169 +the term "modification".) Each licensee is addressed as "you".
171 +Activities other than copying, distribution and modification are not
172 +covered by this License; they are outside its scope. The act of
173 +running the Program is not restricted, and the output from the Program
174 +is covered only if its contents constitute a work based on the
175 +Program (independent of having been made by running the Program).
176 +Whether that is true depends on what the Program does.
178 + 1. You may copy and distribute verbatim copies of the Program's
179 +source code as you receive it, in any medium, provided that you
180 +conspicuously and appropriately publish on each copy an appropriate
181 +copyright notice and disclaimer of warranty; keep intact all the
182 +notices that refer to this License and to the absence of any warranty;
183 +and give any other recipients of the Program a copy of this License
184 +along with the Program.
186 +You may charge a fee for the physical act of transferring a copy, and
187 +you may at your option offer warranty protection in exchange for a fee.
189 + 2. You may modify your copy or copies of the Program or any portion
190 +of it, thus forming a work based on the Program, and copy and
191 +distribute such modifications or work under the terms of Section 1
192 +above, provided that you also meet all of these conditions:
194 + a) You must cause the modified files to carry prominent notices
195 + stating that you changed the files and the date of any change.
197 + b) You must cause any work that you distribute or publish, that in
198 + whole or in part contains or is derived from the Program or any
199 + part thereof, to be licensed as a whole at no charge to all third
200 + parties under the terms of this License.
202 + c) If the modified program normally reads commands interactively
203 + when run, you must cause it, when started running for such
204 + interactive use in the most ordinary way, to print or display an
205 + announcement including an appropriate copyright notice and a
206 + notice that there is no warranty (or else, saying that you provide
207 + a warranty) and that users may redistribute the program under
208 + these conditions, and telling the user how to view a copy of this
209 + License. (Exception: if the Program itself is interactive but
210 + does not normally print such an announcement, your work based on
211 + the Program is not required to print an announcement.)
213 +These requirements apply to the modified work as a whole. If
214 +identifiable sections of that work are not derived from the Program,
215 +and can be reasonably considered independent and separate works in
216 +themselves, then this License, and its terms, do not apply to those
217 +sections when you distribute them as separate works. But when you
218 +distribute the same sections as part of a whole which is a work based
219 +on the Program, the distribution of the whole must be on the terms of
220 +this License, whose permissions for other licensees extend to the
221 +entire whole, and thus to each and every part regardless of who wrote it.
223 +Thus, it is not the intent of this section to claim rights or contest
224 +your rights to work written entirely by you; rather, the intent is to
225 +exercise the right to control the distribution of derivative or
226 +collective works based on the Program.
228 +In addition, mere aggregation of another work not based on the Program
229 +with the Program (or with a work based on the Program) on a volume of
230 +a storage or distribution medium does not bring the other work under
231 +the scope of this License.
233 + 3. You may copy and distribute the Program (or a work based on it,
234 +under Section 2) in object code or executable form under the terms of
235 +Sections 1 and 2 above provided that you also do one of the following:
237 + a) Accompany it with the complete corresponding machine-readable
238 + source code, which must be distributed under the terms of Sections
239 + 1 and 2 above on a medium customarily used for software interchange; or,
241 + b) Accompany it with a written offer, valid for at least three
242 + years, to give any third party, for a charge no more than your
243 + cost of physically performing source distribution, a complete
244 + machine-readable copy of the corresponding source code, to be
245 + distributed under the terms of Sections 1 and 2 above on a medium
246 + customarily used for software interchange; or,
248 + c) Accompany it with the information you received as to the offer
249 + to distribute corresponding source code. (This alternative is
250 + allowed only for noncommercial distribution and only if you
251 + received the program in object code or executable form with such
252 + an offer, in accord with Subsection b above.)
254 +The source code for a work means the preferred form of the work for
255 +making modifications to it. For an executable work, complete source
256 +code means all the source code for all modules it contains, plus any
257 +associated interface definition files, plus the scripts used to
258 +control compilation and installation of the executable. However, as a
259 +special exception, the source code distributed need not include
260 +anything that is normally distributed (in either source or binary
261 +form) with the major components (compiler, kernel, and so on) of the
262 +operating system on which the executable runs, unless that component
263 +itself accompanies the executable.
265 +If distribution of executable or object code is made by offering
266 +access to copy from a designated place, then offering equivalent
267 +access to copy the source code from the same place counts as
268 +distribution of the source code, even though third parties are not
269 +compelled to copy the source along with the object code.
271 + 4. You may not copy, modify, sublicense, or distribute the Program
272 +except as expressly provided under this License. Any attempt
273 +otherwise to copy, modify, sublicense or distribute the Program is
274 +void, and will automatically terminate your rights under this License.
275 +However, parties who have received copies, or rights, from you under
276 +this License will not have their licenses terminated so long as such
277 +parties remain in full compliance.
279 + 5. You are not required to accept this License, since you have not
280 +signed it. However, nothing else grants you permission to modify or
281 +distribute the Program or its derivative works. These actions are
282 +prohibited by law if you do not accept this License. Therefore, by
283 +modifying or distributing the Program (or any work based on the
284 +Program), you indicate your acceptance of this License to do so, and
285 +all its terms and conditions for copying, distributing or modifying
286 +the Program or works based on it.
288 + 6. Each time you redistribute the Program (or any work based on the
289 +Program), the recipient automatically receives a license from the
290 +original licensor to copy, distribute or modify the Program subject to
291 +these terms and conditions. You may not impose any further
292 +restrictions on the recipients' exercise of the rights granted herein.
293 +You are not responsible for enforcing compliance by third parties to
296 + 7. If, as a consequence of a court judgment or allegation of patent
297 +infringement or for any other reason (not limited to patent issues),
298 +conditions are imposed on you (whether by court order, agreement or
299 +otherwise) that contradict the conditions of this License, they do not
300 +excuse you from the conditions of this License. If you cannot
301 +distribute so as to satisfy simultaneously your obligations under this
302 +License and any other pertinent obligations, then as a consequence you
303 +may not distribute the Program at all. For example, if a patent
304 +license would not permit royalty-free redistribution of the Program by
305 +all those who receive copies directly or indirectly through you, then
306 +the only way you could satisfy both it and this License would be to
307 +refrain entirely from distribution of the Program.
309 +If any portion of this section is held invalid or unenforceable under
310 +any particular circumstance, the balance of the section is intended to
311 +apply and the section as a whole is intended to apply in other
314 +It is not the purpose of this section to induce you to infringe any
315 +patents or other property right claims or to contest validity of any
316 +such claims; this section has the sole purpose of protecting the
317 +integrity of the free software distribution system, which is
318 +implemented by public license practices. Many people have made
319 +generous contributions to the wide range of software distributed
320 +through that system in reliance on consistent application of that
321 +system; it is up to the author/donor to decide if he or she is willing
322 +to distribute software through any other system and a licensee cannot
325 +This section is intended to make thoroughly clear what is believed to
326 +be a consequence of the rest of this License.
328 + 8. If the distribution and/or use of the Program is restricted in
329 +certain countries either by patents or by copyrighted interfaces, the
330 +original copyright holder who places the Program under this License
331 +may add an explicit geographical distribution limitation excluding
332 +those countries, so that distribution is permitted only in or among
333 +countries not thus excluded. In such case, this License incorporates
334 +the limitation as if written in the body of this License.
336 + 9. The Free Software Foundation may publish revised and/or new versions
337 +of the General Public License from time to time. Such new versions will
338 +be similar in spirit to the present version, but may differ in detail to
339 +address new problems or concerns.
341 +Each version is given a distinguishing version number. If the Program
342 +specifies a version number of this License which applies to it and "any
343 +later version", you have the option of following the terms and conditions
344 +either of that version or of any later version published by the Free
345 +Software Foundation. If the Program does not specify a version number of
346 +this License, you may choose any version ever published by the Free Software
349 + 10. If you wish to incorporate parts of the Program into other free
350 +programs whose distribution conditions are different, write to the author
351 +to ask for permission. For software which is copyrighted by the Free
352 +Software Foundation, write to the Free Software Foundation; we sometimes
353 +make exceptions for this. Our decision will be guided by the two goals
354 +of preserving the free status of all derivatives of our free software and
355 +of promoting the sharing and reuse of software generally.
359 + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
360 +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
361 +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
362 +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
363 +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
364 +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
365 +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
366 +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
367 +REPAIR OR CORRECTION.
369 + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
370 +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
371 +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
372 +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
373 +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
374 +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
375 +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
376 +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
377 +POSSIBILITY OF SUCH DAMAGES.
379 + END OF TERMS AND CONDITIONS
381 + How to Apply These Terms to Your New Programs
383 + If you develop a new program, and you want it to be of the greatest
384 +possible use to the public, the best way to achieve this is to make it
385 +free software which everyone can redistribute and change under these terms.
387 + To do so, attach the following notices to the program. It is safest
388 +to attach them to the start of each source file to most effectively
389 +convey the exclusion of warranty; and each file should have at least
390 +the "copyright" line and a pointer to where the full notice is found.
392 + <one line to give the program's name and a brief idea of what it does.>
393 + Copyright (C) <year> <name of author>
395 + This program is free software; you can redistribute it and/or modify
396 + it under the terms of the GNU General Public License as published by
397 + the Free Software Foundation; either version 2 of the License, or
398 + (at your option) any later version.
400 + This program is distributed in the hope that it will be useful,
401 + but WITHOUT ANY WARRANTY; without even the implied warranty of
402 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
403 + GNU General Public License for more details.
405 + You should have received a copy of the GNU General Public License
406 + along with this program; if not, write to the Free Software
407 + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
410 +Also add information on how to contact you by electronic and paper mail.
412 +If the program is interactive, make it output a short notice like this
413 +when it starts in an interactive mode:
415 + Gnomovision version 69, Copyright (C) year name of author
416 + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
417 + This is free software, and you are welcome to redistribute it
418 + under certain conditions; type `show c' for details.
420 +The hypothetical commands `show w' and `show c' should show the appropriate
421 +parts of the General Public License. Of course, the commands you use may
422 +be called something other than `show w' and `show c'; they could even be
423 +mouse-clicks or menu items--whatever suits your program.
425 +You should also get your employer (if you work as a programmer) or your
426 +school, if any, to sign a "copyright disclaimer" for the program, if
427 +necessary. Here is a sample; alter the names:
429 + Yoyodyne, Inc., hereby disclaims all copyright interest in the program
430 + `Gnomovision' (which makes passes at compilers) written by James Hacker.
432 + <signature of Ty Coon>, 1 April 1989
433 + Ty Coon, President of Vice
435 +This General Public License does not permit incorporating your program into
436 +proprietary programs. If your program is a subroutine library, you may
437 +consider it more useful to permit linking proprietary applications with the
438 +library. If this is what you want to do, use the GNU Library General
439 +Public License instead of this License.
440 diff --git a/base/cgcs-users/cgcs-users-1.0/COPYRIGHT b/base/cgcs-users/cgcs-users-1.0/COPYRIGHT
442 index 0000000..7507d05
444 +++ b/base/cgcs-users/cgcs-users-1.0/COPYRIGHT
446 +This file is part of IBSH (Iron Bars Shell) , a restricted Unix shell
447 +Copyright (C) 2005 Attila Nagyidai
449 +This program is free software; you can redistribute it and/or
450 +modify it under the terms of the GNU General Public License
451 +as published by the Free Software Foundation; either version 2
452 +of the License, or (at your option) any later version.
454 +This program is distributed in the hope that it will be useful,
455 +but WITHOUT ANY WARRANTY; without even the implied warranty of
456 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
457 +GNU General Public License for more details.
459 +You should have received a copy of the GNU General Public License
460 +along with this program; if not, write to the Free Software
461 +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
463 diff --git a/base/cgcs-users/cgcs-users-1.0/INSTALL b/base/cgcs-users/cgcs-users-1.0/INSTALL
465 index 0000000..42b1866
467 +++ b/base/cgcs-users/cgcs-users-1.0/INSTALL
469 +Installing ibsh is really easy, so no need for the usual sections
470 +in this document. There is no configure script either, so if
471 +something wrong, make will fail.
483 +# make ibsh_uninstall
486 +Of course you will have to enable this shell by:
487 +# echo /bin/ibsh >> /etc/shells
488 +or however you like it.
489 +And make sure the permissions read 0755 !
492 diff --git a/base/cgcs-users/cgcs-users-1.0/Makefile b/base/cgcs-users/cgcs-users-1.0/Makefile
494 index 0000000..ed37d00
496 +++ b/base/cgcs-users/cgcs-users-1.0/Makefile
498 +# This is the makefile for ibsh 0.3e
500 +OBJECTS = main.o command.o jail.o execute.o config.o misc.o antixploit.o delbadfiles.o
502 +ibsh: ${OBJECTS} ibsh.h
503 + ${CC} -o ibsh ${OBJECTS}
505 +main.o: main.c ibsh.h
508 +command.o: command.c ibsh.h
511 +jail.o: jail.c ibsh.h
514 +execute.o: execute.c ibsh.h
517 +config.o: config.c ibsh.h
520 +misc.o: misc.c ibsh.h
523 +antixploit.o: antixploit.c ibsh.h
524 + ${CC} -c antixploit.c
526 +delbadfiles.o: delbadfiles.c ibsh.h
527 + ${CC} -c delbadfiles.c
532 + mkdir /etc/ibsh/cmds
533 + mkdir /etc/ibsh/xtns
534 + cp ./globals.cmds /etc/ibsh/
535 + cp ./globals.xtns /etc/ibsh/
538 + rm -rf /etc/ibsh/globals.cmds
539 + rm -rf /etc/ibsh/globals.xtns
540 + rm -rf /etc/ibsh/cmds/*.*
541 + rm -rf /etc/ibsh/xtns/*.*
542 + rmdir /etc/ibsh/cmds
543 + rmdir /etc/ibsh/xtns
554 diff --git a/base/cgcs-users/cgcs-users-1.0/README b/base/cgcs-users/cgcs-users-1.0/README
556 index 0000000..2035e57
558 +++ b/base/cgcs-users/cgcs-users-1.0/README
560 + Iron Bars SHell - a restricted interactive shell.
564 + For long i have been in the search of a decent restricted shell, but in vain.
565 + The few i found, were really easy to hack, and there were quite a few docs
566 + around on the web about hacking restricted shells with a menu interface.
567 + For my definitions, a restricted shell must not only prevent the user to
568 + escape her jail, but also not to access any files outside the jail.
569 + The system administrator must have total control over the restricted shell.
570 + These are the major features incorporated and realized by ibsh.
575 + Please read the changelog.
580 + Read the INSTALL file.
589 diff --git a/base/cgcs-users/cgcs-users-1.0/Release b/base/cgcs-users/cgcs-users-1.0/Release
591 index 0000000..e6cb9f3
593 +++ b/base/cgcs-users/cgcs-users-1.0/Release
595 +This release introduces minor bugfixes, and important new and renewed features.
596 +Erasing evil files in the home directory of the user is incorporated again, with
597 +many improvements. First of all: no file will be erased! Only the access to them
598 +will be blocked. The extension policy has changed, now ibsh blocks those extensions,
599 +that are NOT listed. This goes in sync with the usual method of operation of ibsh.
600 +The execute permission of files in the user space, will be removed.
601 +New customizing features were added: each user now can have her own commands and
602 +extensions file, created and maintained by the system administrator. Some users
603 +(employees) may require access to special programs. User configuration files allow
604 +this access only those, who need it, not for everybody.
605 +Ibsh now scans not only the extensions of files, but the content too! Whatever the permission
606 +for a certain file exists, if that contains source code, or is a linux binary, access
608 +The absolute path for the users is now limited to 255 characters. Longer, already
609 +existing filenames will be renamed.
612 diff --git a/base/cgcs-users/cgcs-users-1.0/TODO b/base/cgcs-users/cgcs-users-1.0/TODO
614 index 0000000..9a8de60
616 +++ b/base/cgcs-users/cgcs-users-1.0/TODO
622 + - some changes to the prompt, maybe variable prompt.
624 + - to be able to use corporate, or other large/complicated programs in a safe
625 + working environment, yet be able to share files/work with others.
628 diff --git a/base/cgcs-users/cgcs-users-1.0/VERSION b/base/cgcs-users/cgcs-users-1.0/VERSION
630 index 0000000..aaf9552
632 +++ b/base/cgcs-users/cgcs-users-1.0/VERSION
635 diff --git a/base/cgcs-users/cgcs-users-1.0/antixploit.c b/base/cgcs-users/cgcs-users-1.0/antixploit.c
637 index 0000000..79ac9e4
639 +++ b/base/cgcs-users/cgcs-users-1.0/antixploit.c
642 + Created: 03.19.05 11:34:57 by Attila Nagyidai
644 + $Id: C\040Console.c,v 1.1.2.1 2003/08/13 00:38:46 neum Exp $
646 + This file is part of IBSH (Iron Bars Shell) , a restricted Unix shell
647 + Copyright (C) 2005 Attila Nagyidai
649 + This program is free software; you can redistribute it and/or
650 + modify it under the terms of the GNU General Public License
651 + as published by the Free Software Foundation; either version 2
652 + of the License, or (at your option) any later version.
654 + This program is distributed in the hope that it will be useful,
655 + but WITHOUT ANY WARRANTY; without even the implied warranty of
656 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
657 + GNU General Public License for more details.
659 + You should have received a copy of the GNU General Public License
660 + along with this program; if not, write to the Free Software
661 + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
663 + Author: Attila Nagyidai
667 + Email: shy@cpan.org
670 + Email: stazzz@altern.org
672 + URL: http://ibsh.sourceforge.net
673 + IRC: irc.freenode.net #ibsh
674 + RSS, Statistics, etc: http://sourceforge.net/projects/ibsh/
682 +void lshift( char *line )
686 + for (i=0; i<strlen(line) - 1; i++) {
687 + line[i] = line[i+1];
692 +/* Checks if a part of the command line contains */
693 +/* a file in the jail, that is a source code. */
694 +/* Source codes must not be compiled, interpreted, */
695 +/* or otherwise used. */
696 +/* abspath is loggedin.udir, if the token is a path. */
697 +/* otherwise abspath is realpath. */
698 +int antixploit( const char *abspath, char *token )
700 + char jailfile[STRING_SIZE], line[LINE_SIZE], temp[BUFFER_SIZE];
706 + snprintf(jailfile, STRING_SIZE, "%s/%s/%s", loggedin.udir, abspath, token);
708 + printf("jailfile: %s\n", jailfile);
710 + if ( (lstat(jailfile, &info)) == -1 ) {
711 + // this is not a file
715 + fp = fopen(jailfile, "rb");
716 + if ( fp == NULL ) {
717 + // if i cant open it, gcc cant open it
721 + fgets(line, LINE_SIZE, fp);
722 + while ( line[0] != '\0' ) {
724 + printf("Line: %s\n", line);
727 + if ( (strncmp(line, C_CODE, strlen(C_CODE) - 1)) == 0 ) {
731 + // perl, sh, python
732 + if ( (strncmp(line, SHELL_CODE, strlen(SHELL_CODE) - 1)) == 0 ) {
737 + if ( (strncmp(line, PYTHON_CODE, strlen(PYTHON_CODE) - 1)) == 0 ) {
742 + if ( (strncmp(line, ADA_CODE, strlen(ADA_CODE) - 1)) == 0 ) {
747 + if ( (strncmp(line, EIFFEL_CODE, strlen(EIFFEL_CODE) - 1)) == 0 ) {
752 + if ( (strncmp(line, LISP_CODE, strlen(LISP_CODE) - 1)) == 0 ) {
758 + if ( (strncmp(line, ELF_CODE, strlen(ELF_CODE) - 1)) == 0 ) {
762 + bzero(line, LINE_SIZE);
763 + fgets(line, LINE_SIZE, fp);
767 + printf("retval: %d\n", retval);
772 diff --git a/base/cgcs-users/cgcs-users-1.0/command.c b/base/cgcs-users/cgcs-users-1.0/command.c
774 index 0000000..91d9d8f
776 +++ b/base/cgcs-users/cgcs-users-1.0/command.c
779 + Created: 03.19.05 11:34:57 by Attila Nagyidai
781 + $Id: C\040Console.c,v 1.1.2.1 2003/08/13 00:38:46 neum Exp $
783 + This file is part of IBSH (Iron Bars Shell) , a restricted Unix shell
784 + Copyright (C) 2005 Attila Nagyidai
786 + This program is free software; you can redistribute it and/or
787 + modify it under the terms of the GNU General Public License
788 + as published by the Free Software Foundation; either version 2
789 + of the License, or (at your option) any later version.
791 + This program is distributed in the hope that it will be useful,
792 + but WITHOUT ANY WARRANTY; without even the implied warranty of
793 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
794 + GNU General Public License for more details.
796 + You should have received a copy of the GNU General Public License
797 + along with this program; if not, write to the Free Software
798 + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
800 + Author: Attila Nagyidai
804 + Email: shy@cpan.org
807 + Email: stazzz@altern.org
809 + URL: http://ibsh.sourceforge.net
810 + IRC: irc.freenode.net #ibsh
811 + RSS, Statistics, etc: http://sourceforge.net/projects/ibsh/
818 +extern Strng commands[MAX_ITEMS];
820 +/* This is my version of scanf. It offers good protection against */
821 +/* buffer overflow attacks. */
822 +/* Technical Description: */
823 +/* Variables: the char to read to from stdin, the sum of chars typed in, */
824 +/* and an integer for length checking. */
825 +/* Read characters from stdin in a loop, until Enter is pressed. */
826 +/* The line size check wont stop accepting characters, but it will */
827 +/* break long commands to LINE_SIZEd pieces. */
829 +/* Read only 80 characters. If the current path + this 80 chars + / */
830 +/* are longer then 255, read less chars. */
831 +void myscanf( char *vptr, char *abspath )
834 + char chars[STRING_SIZE];
836 + int linesize = LINE_SIZE;
839 + if ( (strlen(abspath)) > (255 - 80 - 1) ) {
840 + linesize = 255 - strlen(abspath) - 1; /* thats for the / */
843 + while ( ((c = getchar()) != 10) && ( i < linesize ) ) {
847 + //ungetc(c, stdin);
853 + openlog("ibsh", LOG_PID, LOG_AUTH);
854 + syslog(LOG_INFO, "user %s has logged out.", loggedin.uname);
859 + /* the user is not allowed to pass long lines of trash to ibsh */
863 + strncpy(vptr,chars,STRING_SIZE-1);
864 + vptr[STRING_SIZE-1] = '\0';
868 +/* Checks, if the user command, is blacklisted, a hack attempt, */
869 +/* or it is a real and allowed command. */
870 +/* Technical Description: */
871 +/* Variables: pointer for the strtok, temporary strings, counters, */
872 +/* and an integer to check, how deep is the user in the jail. That is */
873 +/* the level of subdirectories below jail root. It is set to -1, because */
874 +/* there is always a / in the jailpath. So only subdir /'s are counted. */
875 +/* Check if the command contains special characters, if yes, quit. */
876 +/* If the user is in jailroot, a ../ is not appropriate! */
877 +/* Count the slashes in the jailpath, so if the user uses way too many */
878 +/* ../ 's, then we will know. Split the command to particles by the spaces. */
879 +/* Count the dirups (../); if a token starts with a /, paste the homedir path */
880 +/* right in front of it. Thats your root booby, not / !!!! */
881 +/* Finally check the command against the COMMANDS_LIST. */
882 +int CommandOK( const char *thecommand, const char *rootdir,
883 +const char *jailpath, char *newcommand )
886 + char temp1[STRING_SIZE], *temp2;
888 + int subdirlevel = -1; /* jailpath always starts with a / */
889 + int dirupfound = 0;
892 + /* First, get the fancy stuff: */
893 + /* ../ out of the jailroot, too many ../ out of some */
894 + /* subdirectory in the jail, multiple commands, pipes. */
895 + bzero(newcommand,STRING_SIZE);
897 + if ( (strstr(thecommand, ";")) != NULL ) {
900 + if ( (strstr(thecommand, "|")) != NULL ) {
903 + if ( (strstr(thecommand, "&")) != NULL ) {
906 + if ( (strstr(thecommand, "&&")) != NULL ) {
909 + if ( (strstr(thecommand, "||")) != NULL ) {
912 + /* The user is in the jailroot. */
913 + if ( (strcmp(jailpath, "/")) == 0 ) {
914 + /* Does the user wish to get out ? */
915 + if ( (strstr(thecommand, "..")) != NULL ) {
919 + /* The user is deeper, than the jailroot, and */
920 + /* this is a problem. How deep is he, how many */
921 + /* ../ do we allow ?? */
923 + for (i = 0; i < strlen(jailpath); i++) {
924 + if ( jailpath[i] == '/' ) {
930 + /* Split the command */
931 + for (tok = strtok((void *) thecommand, " "); tok; tok = strtok(0, " ")) {
932 + /* Separate parts of the command with a space */
933 + if ( (strlen(newcommand)) > 0 ) {
934 + strncat(newcommand," ", STRING_SIZE-strlen(newcommand)-1);
937 + /* He wants to get to the real root, does he ? */
938 + /* In that case, add the jailroot to the left. */
939 + if ( tok[0] == '/' ) {
940 + strncat(newcommand,rootdir,STRING_SIZE-strlen(newcommand)-1);
943 + /* how many ../ are here */
944 + /* if too many, that is more, then how deep */
945 + /* the user in the subdirs inside the jail is, */
946 + /* cancel the execution of the command. */
947 + if ( (strstr(tok, "../")) != NULL ) {
948 + strncpy(temp1,tok,sizeof(temp1)-1);
949 + temp1[sizeof(temp1)-1] = '\0';
952 + temp2 = strstr(temp1, "../");
953 + if ( temp2 == NULL ) {
956 + LTrim3(temp2, temp1);
959 + if ( dirupfound > subdirlevel ) {
962 + /* replace dirups with real path */
963 + for (i = 0; i < dirupfound; i++) {
964 + PathMinusOne(jailpath, tok, subdirlevel,sizeof(tok));
967 + /* if command is not listed, return 0 */
969 + while ( ((strlen(commands[i])) > 0) && ( j == 0 ) ) {
970 + if ( (strcmp(tok, commands[i])) == 0 ) {
977 + strncat(newcommand,tok,STRING_SIZE-strlen(newcommand)-1);
981 + printf("old: %s; new: %s; ok: %d\n", thecommand, newcommand, listed);
987 diff --git a/base/cgcs-users/cgcs-users-1.0/config.c b/base/cgcs-users/cgcs-users-1.0/config.c
989 index 0000000..8e2af23
991 +++ b/base/cgcs-users/cgcs-users-1.0/config.c
994 + Created: 03.19.05 11:34:57 by Attila Nagyidai
996 + $Id: C\040Console.c,v 1.1.2.1 2003/08/13 00:38:46 neum Exp $
998 + This file is part of IBSH (Iron Bars Shell) , a restricted Unix shell
999 + Copyright (C) 2005 Attila Nagyidai
1001 + Copyright(c) 2013-2017 Wind River Systems, Inc. All rights reserved.
1003 + This program is free software; you can redistribute it and/or
1004 + modify it under the terms of the GNU General Public License
1005 + as published by the Free Software Foundation; either version 2
1006 + of the License, or (at your option) any later version.
1008 + This program is distributed in the hope that it will be useful,
1009 + but WITHOUT ANY WARRANTY; without even the implied warranty of
1010 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1011 + GNU General Public License for more details.
1013 + You should have received a copy of the GNU General Public License
1014 + along with this program; if not, write to the Free Software
1015 + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1017 + Author: Attila Nagyidai
1021 + Email: shy@cpan.org
1024 + Email: stazzz@altern.org
1026 + URL: http://ibsh.sourceforge.net
1027 + IRC: irc.freenode.net #ibsh
1028 + RSS, Statistics, etc: http://sourceforge.net/projects/ibsh/
1035 +extern Strng commands[MAX_ITEMS];
1036 +extern Strng extensions[MAX_ITEMS];
1038 +/* Shy's improved version of the original (and not well working) loadconfig. */
1039 +/* Reads both config files, and parses the contents into arrays. */
1040 +/* This one effectively dismisses every comment from the files. */
1041 +/* Technical Description: */
1042 +/* Variables: file pointer, counters, temporary string arrays. */
1043 +/* The method is the same for both files. First open the file, catch */
1044 +/* any errors. Read file 'til eof. Not read comments (starting with '#'), */
1045 +/* remove trailing newline character. Copy the finished item to the */
1046 +/* pass-by-address arguments. */
1047 +int LoadConfig( void )
1053 + Strng tmp[MAX_ITEMS];
1054 + Strng tmp2[MAX_ITEMS];
1056 + /* COMMAND CONFIG !!!! */
1057 + file_user = (char *)malloc(strlen(loggedin.uname) + strlen(COMMANDS_DIR) + strlen(".cmds") + 2);
1059 + if(loggedin.uname != NULL)
1060 + sprintf(file_user, "%s/%s.cmds", COMMANDS_DIR, loggedin.uname);
1066 + /* Open global config,if not present go out !!! */
1067 + if((fp = fopen(COMMANDS_FILE,"r")) == NULL) {
1069 + syslog(LOG_ERR, "ibsh panic! Global commands file %s can not be read.", COMMANDS_FILE);
1074 + while (!feof(fp) && (i<MAX_ITEMS)) {
1075 + fgets(tmp[i],STRING_SIZE,fp);
1076 + if ( tmp[i][0] != '#' ) {
1078 + tmp[i][strlen(tmp[i]) - 1] = '\0';
1079 + strncpy(commands[i],tmp[i],strlen(tmp[i]));
1082 + printf("COMMANDS %s\n",commands[i]);
1091 + printf("FILE USER %s\n",file_user);
1093 + /* Add the user command */
1094 + if ((fp = fopen(file_user,"r")) == NULL) {
1100 + while (!feof(fp) && (i<MAX_ITEMS)) {
1101 + fgets(tmp[i],STRING_SIZE,fp);
1102 + if ( tmp[i][0] != '#' ) {
1104 + tmp[i][strlen(tmp[i]) - 1] = '\0';
1105 + strncpy(commands[i],tmp[i],strlen(tmp[i]));
1107 + printf("COMMANDS %s\n",commands[i]);
1119 + /* EXTENSIONS CONFIG !!!!*/
1121 + file_user = (char *)malloc(strlen(loggedin.uname) + strlen(EXTENSIONS_DIR) + strlen(".xtns") + 2);
1123 + sprintf(file_user, "%s/%s.xtns", EXTENSIONS_DIR, loggedin.uname);
1125 + /* Open global config,if not present go out !!! */
1126 + if((fp = fopen(EXTENSIONS_FILE,"r")) == NULL) {
1128 + syslog(LOG_ERR, "ibsh panic! Global extensions file %s can not be read.", EXTENSIONS_FILE);
1130 + printf("heyxtns");
1134 + while (!feof(fp) && (i<MAX_ITEMS)) {
1135 + fgets(tmp2[i],STRING_SIZE,fp);
1136 + if ( tmp2[i][0] != '#' ) {
1138 + tmp2[i][strlen(tmp2[i]) - 1] = '\0';
1139 + strncpy(extensions[i],tmp2[i],strlen(tmp2[i]));
1141 + printf("EXTENSIONS %s\n",extensions[i]);
1149 + /* Add the user extensions */
1150 + if ((fp = fopen(file_user,"r")) == NULL) {
1157 + while (!feof(fp) && (i<MAX_ITEMS)) {
1158 + fgets(tmp2[i],STRING_SIZE,fp);
1159 + if ( tmp2[i][0] != '#' ) {
1161 + tmp2[i][strlen(tmp2[i]) - 1] = '\0';
1162 + strncpy(extensions[i],tmp2[i],strlen(tmp2[i]));
1172 diff --git a/base/cgcs-users/cgcs-users-1.0/delbadfiles.c b/base/cgcs-users/cgcs-users-1.0/delbadfiles.c
1173 new file mode 100644
1174 index 0000000..fc09f4b
1176 +++ b/base/cgcs-users/cgcs-users-1.0/delbadfiles.c
1179 + Created: 03.19.05 11:34:57 by Attila Nagyidai
1181 + $Id: C\040Console.c,v 1.1.2.1 2003/08/13 00:38:46 neum Exp $
1183 + This file is part of IBSH (Iron Bars Shell) , a restricted Unix shell
1184 + Copyright (C) 2005 Attila Nagyidai
1186 + This program is free software; you can redistribute it and/or
1187 + modify it under the terms of the GNU General Public License
1188 + as published by the Free Software Foundation; either version 2
1189 + of the License, or (at your option) any later version.
1191 + This program is distributed in the hope that it will be useful,
1192 + but WITHOUT ANY WARRANTY; without even the implied warranty of
1193 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1194 + GNU General Public License for more details.
1196 + You should have received a copy of the GNU General Public License
1197 + along with this program; if not, write to the Free Software
1198 + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1200 + Author: Attila Nagyidai
1204 + Email: shy@cpan.org
1207 + Email: stazzz@altern.org
1209 + URL: http://ibsh.sourceforge.net
1210 + IRC: irc.freenode.net #ibsh
1211 + RSS, Statistics, etc: http://sourceforge.net/projects/ibsh/
1218 +extern Strng extensions[MAX_ITEMS];
1220 +/* witzy's fix of the DelBadFiles function, making it work and adding features.
1221 + It drops rights of the files which don't end with an extension present into the extensions array,
1222 + deletes symbolic links pointing out of the jail, and makes unexecutable the files that are executable.
1223 + A message is printed each time such a file is found, explaining what was done.
1224 + Don't forget that this function chdirs to the path given into parameter, so when DelBadFiles returns,
1225 + your current working directory is this path.
1227 +void DelBadFiles (const char *basedir)
1230 + struct dirent *list;
1231 + struct stat info, attr;
1232 + char tmp[STRING_SIZE];
1235 + strncpy(tmp, basedir, STRING_SIZE - 1);
1236 + if ( lstat( tmp, &info ) == -1 ) {
1240 + if ( !S_ISDIR(info.st_mode) ) {
1244 + if ( (dp = opendir(tmp)) == NULL ) {
1249 + if ( chdir(tmp) == -1 ) {
1253 + while ( (list = readdir(dp)) != NULL ) {
1255 + printf("direntry: %s\n", list->d_name);
1257 + if ( (lstat(list->d_name, &attr)) < 0 )
1260 + // rename long path names
1262 + printf("length: %d;\n", (strlen(basedir) + strlen(list->d_name) + 2) );
1264 + if ( (strlen(basedir) + strlen(list->d_name) + 2) > 255 ) {
1265 + snprintf(tmp, 255 - strlen(basedir) - 2, "%s", list->d_name);
1266 + rename(list->d_name, tmp);
1268 + printf("%s renamed to %s !\n", list->d_name, tmp);
1270 + if ( (antixploit(basedir, tmp)) == 1 ) {
1271 + removeAllRights(list->d_name, &attr);
1273 + if (isExecutable(&attr)) {
1274 + makeUnexecutable(tmp, &attr);
1279 + if ( S_ISDIR(attr.st_mode) ) { /* in the case of a directory */
1280 + if ( ((strcmp(list->d_name, ".")) != 0) && ((strcmp(list->d_name, "..")) != 0) ) {
1282 + printf("recursive call for %s\n", list->d_name);
1284 + DelBadFiles(list->d_name); /* recursively look for bad files in this directory */
1287 + } else if ( S_ISLNK(attr.st_mode) ) { /* in the case of a symlink */
1288 + if ( symlinkGoesOuttaJail(list->d_name) ) {
1290 + printf("symlinkoutofjail: %s\n", list->d_name);
1292 + if (unlink(list->d_name) == 0) {
1293 + bzero (tmp, sizeof(tmp));
1294 + snprintf (tmp, sizeof(tmp)-1, "Illegal symbolic link %s was erased. Contact the sysadmin for policy.\n", list->d_name);
1295 + logPrintBadfile (tmp);
1298 + } else if (hasSomeRwxRights(&attr)) { /* other cases (in particular a file), only if there are some rights on it */
1300 + printf("%s has some rights\n", list->d_name);
1302 + /* check the runnability of the file */
1303 + if (isExecutable(&attr)) {
1305 + printf("%s executable\n", list->d_name);
1307 + if (makeUnexecutable(list->d_name, &attr) == 0) {
1308 + bzero (tmp, sizeof(tmp));
1309 + snprintf (tmp, sizeof(tmp)-1, "Executable file %s is not anymore. Contact the sysadmin for policy.\n", list->d_name);
1310 + logPrintBadfile (tmp);
1314 + if ( (antixploit(basedir, list->d_name)) == 1 ) {
1315 + if (removeAllRights(list->d_name, &attr) == 0) {
1316 + bzero (tmp, sizeof(tmp));
1317 + snprintf (tmp, sizeof(tmp)-1, "Illegal file %s got its rights dropped. Contact the sysadmin for policy.\n", list->d_name);
1318 + logPrintBadfile (tmp);
1323 + /* check if the file has a permitted extension */
1324 + for (i = 0, allowed = 0; (strlen(extensions[i])) > 0 && !allowed; i++) {
1325 + if ( (strstr(list->d_name, extensions[i])) != NULL ) {
1327 + printf("filename: %s; extension: %s\n", list->d_name, extensions[i]);
1332 + if (!allowed) { /* if the file hasn't an allowed extension */
1334 + printf("not allowed extension for %s\n", list->d_name);
1336 + if (removeAllRights(list->d_name, &attr) == 0) {
1337 + bzero (tmp, sizeof(tmp));
1338 + snprintf (tmp, sizeof(tmp)-1, "Illegal file %s got its rights dropped. Contact the sysadmin for policy.\n", list->d_name);
1339 + logPrintBadfile (tmp);
1349 +/* takes a symlink location, resolves it and returns :
1350 + 1 if the symlink points out of the jail
1351 + 0 else, meaning the symlink is ok
1353 +int symlinkGoesOuttaJail (const char * sl)
1355 + char fPnted[PATH_MAX];
1356 + char rslvdPath[PATH_MAX]; /* size of PATH_MAX because of realpath() behavior */
1359 + i = readlink (sl, fPnted, PATH_MAX);
1360 + if ( i > 0 && i < PATH_MAX ) {
1362 + if (realpath (fPnted, rslvdPath) == rslvdPath) {
1363 + if ( strncmp (loggedin.udir, rslvdPath, strlen(loggedin.udir)) == 0 )
1369 + return 1; /* if this line is reached, there was a problem with the processing of the symlink,
1370 + e.g. the path is too long, so we should consider that the symlink is bad,
1371 + and may be deleted by the calling function */
1374 +/* takes a stat structure, and returns
1375 + 1 if at least one of the user/group/other execution bits or suid/guid are set
1376 + 0 if no such bit is set at all
1378 +int isExecutable (struct stat * s)
1380 + if ( ((s->st_mode & S_IXUSR) == S_IXUSR)
1381 + | ((s->st_mode & S_IXGRP) == S_IXGRP)
1382 + | ((s->st_mode & S_IXOTH) == S_IXOTH)
1383 + | ((s->st_mode & S_ISUID) == S_ISUID)
1384 + | ((s->st_mode & S_ISGID) == S_ISGID) )
1389 +int hasSomeRwxRights (struct stat * s)
1391 + if ( ((s->st_mode & S_IRWXU) != 0)
1392 + | ((s->st_mode & S_IRWXG) != 0)
1393 + | ((s->st_mode & S_IRWXO) != 0) )
1398 +int makeUnexecutable (const char * filename, struct stat * s)
1400 + return chmod (filename,
1401 + s->st_mode & ~(S_IXUSR | S_IXGRP | S_IXOTH | S_ISUID | S_ISGID) );
1404 +int removeAllRights (const char * filename, struct stat * s)
1406 + return chmod (filename,
1407 + s->st_mode & ~(S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID | S_ISGID) );
1410 +void logPrintBadfile (const char * msg)
1413 + syslog(LOG_WARNING, "%s", msg);
1415 + // printf ("ibsh: %s\n", msg);
1417 diff --git a/base/cgcs-users/cgcs-users-1.0/example.allowall.xtns b/base/cgcs-users/cgcs-users-1.0/example.allowall.xtns
1418 new file mode 100644
1419 index 0000000..d0963cd
1421 +++ b/base/cgcs-users/cgcs-users-1.0/example.allowall.xtns
1423 +# Add any extension the user may use.
1451 diff --git a/base/cgcs-users/cgcs-users-1.0/example.denyall.xtns b/base/cgcs-users/cgcs-users-1.0/example.denyall.xtns
1452 new file mode 100644
1453 index 0000000..9dead3a
1455 +++ b/base/cgcs-users/cgcs-users-1.0/example.denyall.xtns
1457 +# Add any extension the user may use.
1459 diff --git a/base/cgcs-users/cgcs-users-1.0/execute.c b/base/cgcs-users/cgcs-users-1.0/execute.c
1460 new file mode 100644
1461 index 0000000..2d80366
1463 +++ b/base/cgcs-users/cgcs-users-1.0/execute.c
1466 + Created: 03.19.05 11:34:57 by Attila Nagyidai
1468 + $Id: C\040Console.c,v 1.1.2.1 2003/08/13 00:38:46 neum Exp $
1470 + This file is part of IBSH (Iron Bars Shell) , a restricted Unix shell
1471 + Copyright (C) 2005 Attila Nagyidai
1473 + This program is free software; you can redistribute it and/or
1474 + modify it under the terms of the GNU General Public License
1475 + as published by the Free Software Foundation; either version 2
1476 + of the License, or (at your option) any later version.
1478 + This program is distributed in the hope that it will be useful,
1479 + but WITHOUT ANY WARRANTY; without even the implied warranty of
1480 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1481 + GNU General Public License for more details.
1483 + You should have received a copy of the GNU General Public License
1484 + along with this program; if not, write to the Free Software
1485 + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1487 + Author: Attila Nagyidai
1491 + Email: shy@cpan.org
1494 + Email: stazzz@altern.org
1496 + URL: http://ibsh.sourceforge.net
1497 + IRC: irc.freenode.net #ibsh
1498 + RSS, Statistics, etc: http://sourceforge.net/projects/ibsh/
1505 +/* Counts the spaces in the command */
1506 +int nbspace(const char *command)
1511 +while(command[i] != '\0'){
1512 + if(command[i] == ' ')
1520 +/* Shy's improved and secured version of hhsystem, originally taken from */
1521 +/* the book: Linux Unix Systemprogramming by Helmut Herold. */
1522 +int hhsystem(const char *user_command) /*--- Version ohne Signalbehandlung ---*/
1531 + char path[STRING_SIZE];
1533 + char *current_path;
1535 + char *params[nbspace(user_command) + 1];
1538 + struct dirent *pdirent;
1540 + if (user_command == NULL)
1541 + return(1); /* In Unix ist immer Kommandoprozessor vorhanden */
1543 + if ( (pid=fork()) < 0)
1546 + else if (pid == 0) {
1547 + /* Split the command */
1548 + field = strtok((char *)user_command," ");
1549 + while(field != NULL){
1551 + printf("CHAMPS %s\n",field);
1553 + params[i] = malloc(strlen(field) + 1);
1554 + bzero(params[i],strlen(field)+1);
1555 + strncpy(params[i],field,strlen(field));
1557 + field = strtok(NULL," ");
1560 + /* Put NULL at the end for execve */
1564 + current_path = getenv("PATH");
1567 + printf("PATH %s %s\n",current_path,loggedin.udir);
1570 + /* Parse the PATH if the command is in the home dir it's skip !! */
1571 + fieldspath = strtok((char *)current_path,":");
1572 + while((fieldspath != NULL) && find != 1){
1574 + printf("FIELD PATH %s\n",fieldspath);
1576 + if(!strstr(fieldspath,loggedin.udir)){
1577 + if((currentdir = opendir(fieldspath)) != NULL){
1579 + while(((pdirent = readdir(currentdir)) != NULL) && find != 1){
1580 + if(!strncmp(pdirent->d_name,params[0],sizeof(params[0]))){
1582 + printf("TROUVE %s!!!!\n",pdirent->d_name);
1589 + closedir(currentdir);
1592 + fieldspath = strtok(NULL,":");
1596 + /* Contruct the real command with the good path */
1597 + if(find == 1 && ((strlen(fieldspath)+strlen(params[0])+1) < sizeof(path))){
1598 + bzero(path,sizeof(path));
1599 + snprintf(path,sizeof(path)-1,"%s/%s",fieldspath,params[0]);
1600 + path[sizeof(path)-1] = '\0';
1603 + printf("PATH FINAL %s %d ok!\n",path,strlen(path));
1604 + printf("PARAMS[0] %s\n",params[0]);
1605 + printf("PARAMS[1] %s\n",params[1]);
1607 + execve(path,params,environ);
1609 + /* The command is in the home dir :( bad for you guys !! */
1616 + while (waitpid(pid, &status, 0) < 0)
1617 + if (errno != EINTR) {
1624 diff --git a/base/cgcs-users/cgcs-users-1.0/globals.cmds b/base/cgcs-users/cgcs-users-1.0/globals.cmds
1625 new file mode 100644
1626 index 0000000..8c9b7a4
1628 +++ b/base/cgcs-users/cgcs-users-1.0/globals.cmds
1630 +# Add any commands the user may execute. Even shell commands.
1631 +# You have to allow logout and/or exit, so the user can logout!
1632 +# cd and pwd should also be allowed. Note: other shell builtin
1633 +# commands are not yet implemented!
1638 diff --git a/base/cgcs-users/cgcs-users-1.0/globals.xtns b/base/cgcs-users/cgcs-users-1.0/globals.xtns
1639 new file mode 100644
1640 index 0000000..71f86f8
1642 +++ b/base/cgcs-users/cgcs-users-1.0/globals.xtns
1644 +# Add any extension the user may use.
1647 diff --git a/base/cgcs-users/cgcs-users-1.0/ibsh.h b/base/cgcs-users/cgcs-users-1.0/ibsh.h
1648 new file mode 100644
1649 index 0000000..9d9d692
1651 +++ b/base/cgcs-users/cgcs-users-1.0/ibsh.h
1654 + Created: 03.19.05 11:15:21 by Attila Nagyidai
1656 + $Id: C\040Header.h,v 1.1.2.1 2003/08/13 00:38:46 neum Exp $
1658 + This file is part of IBSH (Iron Bars Shell) , a restricted Unix shell
1659 + Copyright (C) 2005 Attila Nagyidai
1661 + This program is free software; you can redistribute it and/or
1662 + modify it under the terms of the GNU General Public License
1663 + as published by the Free Software Foundation; either version 2
1664 + of the License, or (at your option) any later version.
1666 + This program is distributed in the hope that it will be useful,
1667 + but WITHOUT ANY WARRANTY; without even the implied warranty of
1668 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1669 + GNU General Public License for more details.
1671 + You should have received a copy of the GNU General Public License
1672 + along with this program; if not, write to the Free Software
1673 + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1675 + Author: Attila Nagyidai
1679 + Email: shy@cpan.org
1681 + URL: http://ibsh.sourceforge.net
1682 + IRC: irc.freenode.net #ibsh
1683 + RSS, Statistics, etc: http://sourceforge.net/projects/ibsh/
1690 +/* Insert Code here */
1692 +#include <stdlib.h>
1693 +#include <string.h>
1695 +#include <unistd.h>
1696 +#include <sys/types.h>
1697 +#include <sys/stat.h>
1698 +#include <sys/wait.h>
1699 +#include <syslog.h>
1702 +#include <dirent.h>
1705 +#include <limits.h>
1707 +#include <signal.h>
1710 +#define LINE_SIZE 80
1711 +#define STRING_SIZE 255
1712 +#define BUFFER_SIZE 4096
1713 +#define PATH_MAX 4096
1714 +#define MAX_ITEMS 50
1715 +#define COMMANDS_DIR "/etc/ibsh/cmds"
1716 +#define COMMANDS_FILE "/etc/ibsh/globals.cmds"
1717 +#define EXTENSIONS_DIR "/etc/ibsh/xtns"
1718 +#define EXTENSIONS_FILE "/etc/ibsh/globals.xtns"
1721 +#define C_CODE "#include"
1722 +#define SHELL_CODE "#!/"
1723 +#define PYTHON_CODE "import"
1724 +#define ADA_CODE "package body"
1725 +#define EIFFEL_CODE "feature --"
1726 +#define LISP_CODE "(defun"
1727 +#define ELF_CODE "ELF"
1730 +#define OPENLOG openlog("ibsh", LOG_PID, LOG_AUTH)
1731 +#define CLOSELOG closelog()
1733 +/* Typedefs, structs, globals */
1734 +typedef struct theuser {
1735 + char uname[STRING_SIZE];
1737 + char udir[STRING_SIZE];
1738 + struct passwd *record;
1741 +typedef char Strng[STRING_SIZE];
1743 +theuser loggedin; /* user info */
1745 +//static Strng commands[MAX_ITEMS]; /* permitted commands */
1746 +Strng commands[MAX_ITEMS];
1747 +Strng extensions[MAX_ITEMS];
1748 +/*static Strng extensions[MAX_ITEMS]; permitted extensions */
1749 +char real_path[STRING_SIZE]; /* absolute path */
1750 +char jail_path[STRING_SIZE]; /* path inside the jail */
1751 +char user_command[STRING_SIZE]; /* whatever the user types */
1752 +char filtered_command[STRING_SIZE]; /* this one will be executed */
1754 +extern char **environ;
1757 +int CommandOK( const char *thecommand, const char *rootdir,
1758 +const char *jailpath, char *newcommand );
1759 +void LTrim3( const char *base, char *result );
1760 +void GetPositionInJail( const char *abspath, const char *rootdir, char *relpath );
1761 +int LoadConfig( void );
1762 +void myscanf( char *vptr, char *abspath );
1763 +int hhsystem(const char *kdozeile);
1764 +void PathMinusOne( const char *basepath, char *evalpath, int slashcount,size_t nevalpath);
1765 +void log_attempt( const char *username );
1766 +int nbspace(const char *command);
1767 +void lshift( char *line );
1768 +int antixploit( const char *abspath, char *token );
1769 +void logPrintBadfile (const char * msg);
1770 +int removeAllRights (const char * filename, struct stat * s);
1771 +int makeUnexecutable (const char * filename, struct stat * s);
1772 +int hasSomeRwxRights (struct stat * s);
1773 +int isExecutable (struct stat * s);
1774 +int symlinkGoesOuttaJail (const char * sl);
1775 +void DelBadFiles (const char *basedir);
1778 +#endif /* _IBSH_H */
1779 diff --git a/base/cgcs-users/cgcs-users-1.0/jail.c b/base/cgcs-users/cgcs-users-1.0/jail.c
1780 new file mode 100644
1781 index 0000000..ab3300a
1783 +++ b/base/cgcs-users/cgcs-users-1.0/jail.c
1786 + Created: 03.19.05 11:34:57 by Attila Nagyidai
1788 + $Id: C\040Console.c,v 1.1.2.1 2003/08/13 00:38:46 neum Exp $
1790 + This file is part of IBSH (Iron Bars Shell) , a restricted Unix shell
1791 + Copyright (C) 2005 Attila Nagyidai
1793 + This program is free software; you can redistribute it and/or
1794 + modify it under the terms of the GNU General Public License
1795 + as published by the Free Software Foundation; either version 2
1796 + of the License, or (at your option) any later version.
1798 + This program is distributed in the hope that it will be useful,
1799 + but WITHOUT ANY WARRANTY; without even the implied warranty of
1800 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1801 + GNU General Public License for more details.
1803 + You should have received a copy of the GNU General Public License
1804 + along with this program; if not, write to the Free Software
1805 + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1807 + Author: Attila Nagyidai
1811 + Email: shy@cpan.org
1814 + Email: stazzz@altern.org
1816 + URL: http://ibsh.sourceforge.net
1817 + IRC: irc.freenode.net #ibsh
1818 + RSS, Statistics, etc: http://sourceforge.net/projects/ibsh/
1827 +/* Remove the path of the Jail root dir from the displayed paths! */
1828 +/* Return the jail path from the absolute path. */
1829 +/* Copy characters from absolute path to jail path, starting, where the */
1830 +/* jail root ends. */
1831 +void GetPositionInJail( const char *abspath, const char *rootdir, char *relpath )
1836 + bzero(relpath, strlen(relpath));
1837 + for (i = strlen(rootdir); i < strlen(abspath); i++) {
1838 + relpath[j] = abspath[i];
1841 + relpath[j] = '\0';
1844 +/* Take 3 characters from left off a string. */
1845 +/* It practically removes one ../ . */
1846 +void LTrim3( const char *base, char *result )
1851 + bzero(result, strlen(result));
1852 + for (i = 3; i < strlen(base); i++) {
1853 + result[j] = base[i];
1859 +/* Remove one subdirectory from the path in the argument. */
1860 +/* In case the user uses ../ 's in his command. */
1861 +/* Technical Description: */
1862 +/* Variables: string pointer for the strtok function, and an */
1863 +/* integer to stop the removing. */
1864 +/* Disassemble the path by the slashes. And glue the required parts */
1865 +/* together. Number of required parts = number of all parts - 1 . */
1866 +void PathMinusOne( const char *basepath, char *evalpath, int slashcount,size_t nevalpath )
1871 + bzero(evalpath, strlen(evalpath));
1872 + if ( slashcount == 1 ) {
1873 + strncpy(evalpath,"/",nevalpath-1);
1874 + evalpath[nevalpath-1] = '\0';
1877 + for (tok = strtok((void *) basepath, "/"); tok; tok = strtok(0, "/")) {
1878 + if ( j < slashcount ) {
1879 + strncat(evalpath,tok,nevalpath-strlen(evalpath)-1);
1880 + strncat(evalpath,"/",nevalpath-strlen(evalpath)-1);
1886 diff --git a/base/cgcs-users/cgcs-users-1.0/main.c b/base/cgcs-users/cgcs-users-1.0/main.c
1887 new file mode 100644
1888 index 0000000..1d92899
1890 +++ b/base/cgcs-users/cgcs-users-1.0/main.c
1893 + Created: 03.19.05 11:34:57 by Attila Nagyidai
1895 + $Id: C\040Console.c,v 1.1.2.1 2003/08/13 00:38:46 neum Exp $
1897 + This file is part of IBSH (Iron Bars Shell) , a restricted Unix shell
1898 + Copyright (C) 2005 Attila Nagyidai
1900 + Copyright(c) 2013-2017 Wind River Systems, Inc. All rights reserved.
1902 + This program is free software; you can redistribute it and/or
1903 + modify it under the terms of the GNU General Public License
1904 + as published by the Free Software Foundation; either version 2
1905 + of the License, or (at your option) any later version.
1907 + This program is distributed in the hope that it will be useful,
1908 + but WITHOUT ANY WARRANTY; without even the implied warranty of
1909 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1910 + GNU General Public License for more details.
1912 + You should have received a copy of the GNU General Public License
1913 + along with this program; if not, write to the Free Software
1914 + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1916 + Author: Attila Nagyidai
1920 + Email: shy@cpan.org
1923 + Email: stazzz@altern.org
1925 + URL: http://ibsh.sourceforge.net
1926 + IRC: irc.freenode.net #ibsh
1927 + RSS, Statistics, etc: http://sourceforge.net/projects/ibsh/
1933 +#include "stdlib.h"
1936 +/* Handle arguments, read config files, start command processing. */
1937 +/* IBSH doesnt use any command line arguments, but my text editor */
1938 +/* uses this code in all new c files to create. And i didnt have the */
1939 +/* heart to remove it. ;p */
1940 +/* Technical Description: */
1941 +/* Get the passwd entry for the user. The uid is easily aquired, since */
1942 +/* it is the real user id. After that, grab the passwd file entry upon */
1943 +/* the id, and copy the information to the loggedin struct. */
1944 +/* Add some signal handlers too. */
1945 +/* The infinite loop: */
1946 +/* Get the current directory, the full path. Compute the jailpath from that, */
1947 +/* that is the directories below the users homedir, which is the jail root. */
1948 +/* The jail ceiling if you like. Print some prompt to the user with the jailpath, */
1949 +/* and read stdin for incoming commands. Filter out the bad commands, typos, the */
1950 +/* not allowed commands. It the command is ok, execute it. If it is a shell builtin, */
1951 +/* use our builtin code, otherwise use execve. After execve, check if the user didnt */
1952 +/* use the last command to create some illegal content. If yes, erase that. Give the */
1953 +/* notice only afterwards. */
1955 +void ALRMhandler(int sig) {
1957 + syslog(LOG_INFO, "CLI timeout, user %s has logged out.", loggedin.uname);
1962 +int main(int argc, char **argv)
1964 + char temp[STRING_SIZE], *buf;
1968 + unsigned int tout_cli = 0;
1970 + const char* tout = getenv("TMOUT");
1972 + tout_cli = atoi(tout);
1974 + //default to 5 mins
1977 + /* setuid protection */
1982 + if ( (ruid!=euid) || (ruid==0) || (euid==0) || (rgid!=egid) || (rgid==0) || (egid==0) ) {
1984 + syslog(LOG_ERR, "setuid/setgid violation!");
1986 + printf("ibsh: setuid/setgid violation!! exiting...\n");
1988 + printf("ruid: %d;euid: %d;rgid: %d;egid: %d\n", ruid,euid,rgid,egid);
1993 + /* To Do: The code of your application goes here */
1995 + /* Get essential information about the user who got this shell: */
1996 + /* first the username, then the user id. Upon this, retrieve the */
1997 + /* user's record in the passwd file. */
1998 + bzero(&loggedin, sizeof(loggedin));
1999 + loggedin.uid = getuid();
2000 + loggedin.record = getpwuid(loggedin.uid);
2001 + if ( loggedin.record == NULL ) {
2002 + loggedin.record = getpwnam(loggedin.uname);
2003 + if ( loggedin.record == NULL ) {
2004 + openlog(loggedin.uname, LOG_PID, LOG_AUTH);
2005 + syslog(LOG_ERR, "Can not obtain user information");
2010 + strncpy(loggedin.uname, loggedin.record->pw_name, PAM_SIZE);
2011 + strncpy(loggedin.udir, loggedin.record->pw_dir, STRING_SIZE);
2013 + /* Second part: */
2014 + /* Handle some signal catching. Read the configuration files. */
2015 + signal( SIGINT, SIG_IGN );
2016 + signal( SIGQUIT, SIG_IGN );
2017 + signal( SIGTERM, SIG_IGN );
2018 + signal( SIGTSTP, SIG_IGN );
2019 + signal( SIGALRM, ALRMhandler );
2022 + /* Command mode */
2024 + if ( argv[1][1] == 'c' ) {
2025 + if ( CommandOK(argv[2], loggedin.udir, "/", filtered_command) == 1) {
2026 + exitcode = hhsystem(filtered_command);
2028 + syslog(LOG_INFO, "command %s ordered, command %s has been executed.",
2029 + argv[2], filtered_command);
2041 + syslog(LOG_INFO, "user %s has logged in.", loggedin.uname);
2045 + DelBadFiles(loggedin.udir);
2046 + chdir (loggedin.udir);
2050 + /* Start reading and processing the user issued commands. */
2051 + /* Split the command by the spaces, filter out anything, */
2052 + /* that would allow the user to access files outside the */
2053 + /* jail. Filter out multiples and pipes as well. No program */
2054 + /* will be allowed to run, unless it is mentioned in the */
2055 + /* config files. Files that are created with an extension */
2056 + /* that is listed in the other config file, must be deleted! */
2059 + /* Where is he ? */
2060 + getcwd(real_path, STRING_SIZE);
2061 + GetPositionInJail(real_path, loggedin.udir, jail_path);
2062 + if ( (strlen(jail_path)) == 0 ) {
2063 + strncpy(jail_path, "/", 2);
2065 + /* We don't want the user to know where he actually is. */
2066 + /* This is the prompt! */
2067 + printf("[%s]%% ", loggedin.uname);
2068 + /* scanf("%s", user_command); */
2069 + myscanf(user_command, real_path);
2071 + /* Command interpretation and execution. */
2072 + if ( (CommandOK(user_command, loggedin.udir, jail_path, filtered_command)) == 0 ) {
2073 + log_attempt(loggedin.uname); /* v0.2a */
2076 + /* If the user issued command starts with a shell builtin. */
2077 + bzero(temp, strlen(temp));
2078 + if ( (buf = strstr(filtered_command, "cd")) != NULL ) {
2079 + if ( (strcmp(buf, filtered_command)) == 0 ) {
2080 + LTrim3(filtered_command, temp);
2081 + if ( (strcmp(temp, real_path)) != 0 ) {
2082 + if ( (strcmp(temp, "..")) == 0 ) {
2083 + PathMinusOne(jail_path, temp, 1,sizeof(temp));
2085 + if ( (strcmp(temp, "/")) == 0 ) {
2086 + strncpy(temp, loggedin.udir, LINE_SIZE);
2088 + exitcode = chdir(temp);
2089 + if ( exitcode == -1 ) {
2090 + printf("ibsh: cd: %s: No such file or directory\n", temp);
2096 + else if ( (buf = strstr(filtered_command, "pwd")) != NULL ) {
2097 + if ( (strcmp(buf, filtered_command)) == 0 ) {
2098 + printf("%s\n", jail_path);
2102 + else if ( (buf = strstr(filtered_command, "logout")) != NULL ) {
2103 + if ( (strcmp(buf, filtered_command)) == 0 ) {
2105 + syslog(LOG_INFO, "user %s has logged out.", loggedin.uname);
2110 + else if ( (buf = strstr(filtered_command, "exit")) != NULL ) {
2111 + if ( (strcmp(buf, filtered_command)) == 0 ) {
2113 + syslog(LOG_INFO, "user %s has logged out.", loggedin.uname);
2119 + exitcode = hhsystem(filtered_command);
2120 + if ( exitcode < 0 ) {
2121 + printf("%s\n", strerror(errno));
2124 + getcwd(real_path, STRING_SIZE);
2125 + DelBadFiles(loggedin.udir);
2126 + chdir (real_path);
2131 diff --git a/base/cgcs-users/cgcs-users-1.0/misc.c b/base/cgcs-users/cgcs-users-1.0/misc.c
2132 new file mode 100644
2133 index 0000000..d73ddb8
2135 +++ b/base/cgcs-users/cgcs-users-1.0/misc.c
2138 + Created: 03.19.05 11:34:57 by Attila Nagyidai
2140 + $Id: C\040Console.c,v 1.1.2.1 2003/08/13 00:38:46 neum Exp $
2142 + This file is part of IBSH (Iron Bars Shell) , a restricted Unix shell
2143 + Copyright (C) 2005 Attila Nagyidai
2145 + This program is free software; you can redistribute it and/or
2146 + modify it under the terms of the GNU General Public License
2147 + as published by the Free Software Foundation; either version 2
2148 + of the License, or (at your option) any later version.
2150 + This program is distributed in the hope that it will be useful,
2151 + but WITHOUT ANY WARRANTY; without even the implied warranty of
2152 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2153 + GNU General Public License for more details.
2155 + You should have received a copy of the GNU General Public License
2156 + along with this program; if not, write to the Free Software
2157 + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2159 + Author: Attila Nagyidai
2163 + Email: shy@cpan.org
2166 + Email: stazzz@altern.org
2168 + URL: http://ibsh.sourceforge.net
2169 + IRC: irc.freenode.net #ibsh
2170 + RSS, Statistics, etc: http://sourceforge.net/projects/ibsh/
2177 +/* If the command is not ok, there is a possible hack attempt. */
2178 +/* Can also be a typo, but we're not taking any chances. v0.2a */
2179 +void log_attempt( const char *username )
2181 + char logmsg[STRING_SIZE];
2183 + snprintf(logmsg, 50, "Possible hack attempt by %s.", username);
2186 + syslog(LOG_WARNING, "%s", logmsg);