Revert "Revert "oran-shell-release: release image for F""
[pti/rtp.git] / meta-starlingx / meta-stx-flock / stx-integ / files / ibsh / ibsh-0.3e.patch
1 Index: cgcs-users-1.0-r0/AUTHORS.orig
2 ===================================================================
3 --- /dev/null
4 +++ cgcs-users-1.0-r0/AUTHORS.orig
5 @@ -0,0 +1,15 @@
6 +AUTHORS OF PROJECT IBSH
7 +
8 +Attila Nagyidai <attila at ibsh.net>
9 +       * Original program author, project admin, developer.
10 +
11 +Shy <shy at ibsh.net>
12 +       * Developer, debugger, tester, and many more.
13 +
14 +Witzy <witzy at ibsh.net>
15 +       * Developer, debugger, tester, and many more.
16 +
17 +http://www.ibsh.net
18 +irc:
19 +irc.freenode.net #ibsh
20 +irc.geek-power.org #ibsh
21 Index: cgcs-users-1.0-r0/BUGS.orig
22 ===================================================================
23 --- /dev/null
24 +++ cgcs-users-1.0-r0/BUGS.orig
25 @@ -0,0 +1,19 @@
26 +** Open BUGS **
27 +None, so far.
28 +
29 +** Fixed BUGS **
30 +- Input length checking on all inputs, string copies, etc. is fixed.
31 +- The myscanf function will no longer accept more then 80 chars at once,
32 +so ibsh hopefully wont crash on a too long input.
33 +- Added signal.h in the header file, the lack of it caused compilation
34 +problems on some systems.
35 +- Fixed the infinite loop in DelBadFiles. This function is temporarily 
36 +taken out of the project
37 +- Removed the involvment of /bin/sh from system. Added path checking.
38 +- In jail root, not only ../ is not allowed, but .. too.
39 +- Fixed a bug, that happened on bsd, when the user pressed ^D.
40 +- Fixed a bug with opendir
41 +- Fixed a format string vulnerability in logprintbadfile(). Thanks to
42 +Kim Streich for the report.
43 +
44 +2005.05.23
45 Index: cgcs-users-1.0-r0/ChangeLog.orig
46 ===================================================================
47 --- /dev/null
48 +++ cgcs-users-1.0-r0/ChangeLog.orig
49 @@ -0,0 +1,34 @@
50 +0.3e - a buffer overflow and a string bug, both found by RazoR (Nikolay Alexandrov), fixed.
51 +0.3d - a format string vulnerability, found by Kim Streich, is fixed.
52 +0.3b-0.3c - bugfixes.
53 +0.3a   - The admin has the opportunity, to create separate cmds file for each user. 
54 +       This way the sysadmin has complete control over sensitive applications, which
55 +       should only be allowed to a selected few.
56 +       - The admin has the opportunity, to create separate xtns file for each user. 
57 +       - The extensions policy has been changed. Now both globals.xtns and the user
58 +       extension files will list the extensions, that are _allowed_ ! In earlier versions,
59 +       the forbidden extensions were listed, that is allow everything, except to deny a few.
60 +       From this version on, it's deny everything, except allow the ones, listed in these files.
61 +       - While the code for the search of illegal/dangerous material stored in user space is
62 +       back, it will not erase any files any more. Instead, it will remove all
63 +       rights from that file, so it can not be executed, or read. Files, with the +x bit set,
64 +       will be chmodded to -x. This is another "defense line" to stop the user to execute
65 +       programs, stored in user space.
66 +       - The access to all linux binaries, and source code files, stored in user space, if any, 
67 +       will be blocked.
68 +       - Absolute path for restricted users can not be longer then 255 characters. All files,
69 +       that are longer (with full path), will be renamed.
70 +       - Minor bug fixes.
71 +
72 +0.2a   - Major bug fixes. 
73 +       - User activities are logged with syslog.
74 +       - hhsytem revised, hardened. /bin/sh isnt involved anymore into program starting.
75 +       If the home directory is in the PATH, it's ignored.
76 +       - erasing illegal content is temporarily suspended and removed.
77 +
78 +0.1b   - Major bug fixes.
79 +       - The config files are accidentally missing from this release!
80 +
81 +0.1a   - The first version of the program.
82 +
83 +2005.05.23.
84 Index: cgcs-users-1.0-r0/CONTRIBUTORS.orig
85 ===================================================================
86 --- /dev/null
87 +++ cgcs-users-1.0-r0/CONTRIBUTORS.orig
88 @@ -0,0 +1,7 @@
89 +CONTRIBUTORS TO PROJECT IBSH
90 +
91 +Kim Streich <kstreich at gmail.com>
92 +       * bug finder, debugger, tester.
93 +
94 +RazoR (Nikolay Alexandrov) <Nikolay@Alexandrov.ws>
95 +       * bug finder, debugger, tester.
96 Index: cgcs-users-1.0-r0/COPYING.orig
97 ===================================================================
98 --- /dev/null
99 +++ cgcs-users-1.0-r0/COPYING.orig
100 @@ -0,0 +1,340 @@
101 +                   GNU GENERAL PUBLIC LICENSE
102 +                      Version 2, June 1991
103 +
104 + Copyright (C) 1989, 1991 Free Software Foundation, Inc.
105 +     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
106 + Everyone is permitted to copy and distribute verbatim copies
107 + of this license document, but changing it is not allowed.
108 +
109 +                           Preamble
110 +
111 +  The licenses for most software are designed to take away your
112 +freedom to share and change it.  By contrast, the GNU General Public
113 +License is intended to guarantee your freedom to share and change free
114 +software--to make sure the software is free for all its users.  This
115 +General Public License applies to most of the Free Software
116 +Foundation's software and to any other program whose authors commit to
117 +using it.  (Some other Free Software Foundation software is covered by
118 +the GNU Library General Public License instead.)  You can apply it to
119 +your programs, too.
120 +
121 +  When we speak of free software, we are referring to freedom, not
122 +price.  Our General Public Licenses are designed to make sure that you
123 +have the freedom to distribute copies of free software (and charge for
124 +this service if you wish), that you receive source code or can get it
125 +if you want it, that you can change the software or use pieces of it
126 +in new free programs; and that you know you can do these things.
127 +
128 +  To protect your rights, we need to make restrictions that forbid
129 +anyone to deny you these rights or to ask you to surrender the rights.
130 +These restrictions translate to certain responsibilities for you if you
131 +distribute copies of the software, or if you modify it.
132 +
133 +  For example, if you distribute copies of such a program, whether
134 +gratis or for a fee, you must give the recipients all the rights that
135 +you have.  You must make sure that they, too, receive or can get the
136 +source code.  And you must show them these terms so they know their
137 +rights.
138 +
139 +  We protect your rights with two steps: (1) copyright the software, and
140 +(2) offer you this license which gives you legal permission to copy,
141 +distribute and/or modify the software.
142 +
143 +  Also, for each author's protection and ours, we want to make certain
144 +that everyone understands that there is no warranty for this free
145 +software.  If the software is modified by someone else and passed on, we
146 +want its recipients to know that what they have is not the original, so
147 +that any problems introduced by others will not reflect on the original
148 +authors' reputations.
149 +
150 +  Finally, any free program is threatened constantly by software
151 +patents.  We wish to avoid the danger that redistributors of a free
152 +program will individually obtain patent licenses, in effect making the
153 +program proprietary.  To prevent this, we have made it clear that any
154 +patent must be licensed for everyone's free use or not licensed at all.
155 +
156 +  The precise terms and conditions for copying, distribution and
157 +modification follow.
158 +\f
159 +                   GNU GENERAL PUBLIC LICENSE
160 +   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
161 +
162 +  0. This License applies to any program or other work which contains
163 +a notice placed by the copyright holder saying it may be distributed
164 +under the terms of this General Public License.  The "Program", below,
165 +refers to any such program or work, and a "work based on the Program"
166 +means either the Program or any derivative work under copyright law:
167 +that is to say, a work containing the Program or a portion of it,
168 +either verbatim or with modifications and/or translated into another
169 +language.  (Hereinafter, translation is included without limitation in
170 +the term "modification".)  Each licensee is addressed as "you".
171 +
172 +Activities other than copying, distribution and modification are not
173 +covered by this License; they are outside its scope.  The act of
174 +running the Program is not restricted, and the output from the Program
175 +is covered only if its contents constitute a work based on the
176 +Program (independent of having been made by running the Program).
177 +Whether that is true depends on what the Program does.
178 +
179 +  1. You may copy and distribute verbatim copies of the Program's
180 +source code as you receive it, in any medium, provided that you
181 +conspicuously and appropriately publish on each copy an appropriate
182 +copyright notice and disclaimer of warranty; keep intact all the
183 +notices that refer to this License and to the absence of any warranty;
184 +and give any other recipients of the Program a copy of this License
185 +along with the Program.
186 +
187 +You may charge a fee for the physical act of transferring a copy, and
188 +you may at your option offer warranty protection in exchange for a fee.
189 +
190 +  2. You may modify your copy or copies of the Program or any portion
191 +of it, thus forming a work based on the Program, and copy and
192 +distribute such modifications or work under the terms of Section 1
193 +above, provided that you also meet all of these conditions:
194 +
195 +    a) You must cause the modified files to carry prominent notices
196 +    stating that you changed the files and the date of any change.
197 +
198 +    b) You must cause any work that you distribute or publish, that in
199 +    whole or in part contains or is derived from the Program or any
200 +    part thereof, to be licensed as a whole at no charge to all third
201 +    parties under the terms of this License.
202 +
203 +    c) If the modified program normally reads commands interactively
204 +    when run, you must cause it, when started running for such
205 +    interactive use in the most ordinary way, to print or display an
206 +    announcement including an appropriate copyright notice and a
207 +    notice that there is no warranty (or else, saying that you provide
208 +    a warranty) and that users may redistribute the program under
209 +    these conditions, and telling the user how to view a copy of this
210 +    License.  (Exception: if the Program itself is interactive but
211 +    does not normally print such an announcement, your work based on
212 +    the Program is not required to print an announcement.)
213 +\f
214 +These requirements apply to the modified work as a whole.  If
215 +identifiable sections of that work are not derived from the Program,
216 +and can be reasonably considered independent and separate works in
217 +themselves, then this License, and its terms, do not apply to those
218 +sections when you distribute them as separate works.  But when you
219 +distribute the same sections as part of a whole which is a work based
220 +on the Program, the distribution of the whole must be on the terms of
221 +this License, whose permissions for other licensees extend to the
222 +entire whole, and thus to each and every part regardless of who wrote it.
223 +
224 +Thus, it is not the intent of this section to claim rights or contest
225 +your rights to work written entirely by you; rather, the intent is to
226 +exercise the right to control the distribution of derivative or
227 +collective works based on the Program.
228 +
229 +In addition, mere aggregation of another work not based on the Program
230 +with the Program (or with a work based on the Program) on a volume of
231 +a storage or distribution medium does not bring the other work under
232 +the scope of this License.
233 +
234 +  3. You may copy and distribute the Program (or a work based on it,
235 +under Section 2) in object code or executable form under the terms of
236 +Sections 1 and 2 above provided that you also do one of the following:
237 +
238 +    a) Accompany it with the complete corresponding machine-readable
239 +    source code, which must be distributed under the terms of Sections
240 +    1 and 2 above on a medium customarily used for software interchange; or,
241 +
242 +    b) Accompany it with a written offer, valid for at least three
243 +    years, to give any third party, for a charge no more than your
244 +    cost of physically performing source distribution, a complete
245 +    machine-readable copy of the corresponding source code, to be
246 +    distributed under the terms of Sections 1 and 2 above on a medium
247 +    customarily used for software interchange; or,
248 +
249 +    c) Accompany it with the information you received as to the offer
250 +    to distribute corresponding source code.  (This alternative is
251 +    allowed only for noncommercial distribution and only if you
252 +    received the program in object code or executable form with such
253 +    an offer, in accord with Subsection b above.)
254 +
255 +The source code for a work means the preferred form of the work for
256 +making modifications to it.  For an executable work, complete source
257 +code means all the source code for all modules it contains, plus any
258 +associated interface definition files, plus the scripts used to
259 +control compilation and installation of the executable.  However, as a
260 +special exception, the source code distributed need not include
261 +anything that is normally distributed (in either source or binary
262 +form) with the major components (compiler, kernel, and so on) of the
263 +operating system on which the executable runs, unless that component
264 +itself accompanies the executable.
265 +
266 +If distribution of executable or object code is made by offering
267 +access to copy from a designated place, then offering equivalent
268 +access to copy the source code from the same place counts as
269 +distribution of the source code, even though third parties are not
270 +compelled to copy the source along with the object code.
271 +\f
272 +  4. You may not copy, modify, sublicense, or distribute the Program
273 +except as expressly provided under this License.  Any attempt
274 +otherwise to copy, modify, sublicense or distribute the Program is
275 +void, and will automatically terminate your rights under this License.
276 +However, parties who have received copies, or rights, from you under
277 +this License will not have their licenses terminated so long as such
278 +parties remain in full compliance.
279 +
280 +  5. You are not required to accept this License, since you have not
281 +signed it.  However, nothing else grants you permission to modify or
282 +distribute the Program or its derivative works.  These actions are
283 +prohibited by law if you do not accept this License.  Therefore, by
284 +modifying or distributing the Program (or any work based on the
285 +Program), you indicate your acceptance of this License to do so, and
286 +all its terms and conditions for copying, distributing or modifying
287 +the Program or works based on it.
288 +
289 +  6. Each time you redistribute the Program (or any work based on the
290 +Program), the recipient automatically receives a license from the
291 +original licensor to copy, distribute or modify the Program subject to
292 +these terms and conditions.  You may not impose any further
293 +restrictions on the recipients' exercise of the rights granted herein.
294 +You are not responsible for enforcing compliance by third parties to
295 +this License.
296 +
297 +  7. If, as a consequence of a court judgment or allegation of patent
298 +infringement or for any other reason (not limited to patent issues),
299 +conditions are imposed on you (whether by court order, agreement or
300 +otherwise) that contradict the conditions of this License, they do not
301 +excuse you from the conditions of this License.  If you cannot
302 +distribute so as to satisfy simultaneously your obligations under this
303 +License and any other pertinent obligations, then as a consequence you
304 +may not distribute the Program at all.  For example, if a patent
305 +license would not permit royalty-free redistribution of the Program by
306 +all those who receive copies directly or indirectly through you, then
307 +the only way you could satisfy both it and this License would be to
308 +refrain entirely from distribution of the Program.
309 +
310 +If any portion of this section is held invalid or unenforceable under
311 +any particular circumstance, the balance of the section is intended to
312 +apply and the section as a whole is intended to apply in other
313 +circumstances.
314 +
315 +It is not the purpose of this section to induce you to infringe any
316 +patents or other property right claims or to contest validity of any
317 +such claims; this section has the sole purpose of protecting the
318 +integrity of the free software distribution system, which is
319 +implemented by public license practices.  Many people have made
320 +generous contributions to the wide range of software distributed
321 +through that system in reliance on consistent application of that
322 +system; it is up to the author/donor to decide if he or she is willing
323 +to distribute software through any other system and a licensee cannot
324 +impose that choice.
325 +
326 +This section is intended to make thoroughly clear what is believed to
327 +be a consequence of the rest of this License.
328 +\f
329 +  8. If the distribution and/or use of the Program is restricted in
330 +certain countries either by patents or by copyrighted interfaces, the
331 +original copyright holder who places the Program under this License
332 +may add an explicit geographical distribution limitation excluding
333 +those countries, so that distribution is permitted only in or among
334 +countries not thus excluded.  In such case, this License incorporates
335 +the limitation as if written in the body of this License.
336 +
337 +  9. The Free Software Foundation may publish revised and/or new versions
338 +of the General Public License from time to time.  Such new versions will
339 +be similar in spirit to the present version, but may differ in detail to
340 +address new problems or concerns.
341 +
342 +Each version is given a distinguishing version number.  If the Program
343 +specifies a version number of this License which applies to it and "any
344 +later version", you have the option of following the terms and conditions
345 +either of that version or of any later version published by the Free
346 +Software Foundation.  If the Program does not specify a version number of
347 +this License, you may choose any version ever published by the Free Software
348 +Foundation.
349 +
350 +  10. If you wish to incorporate parts of the Program into other free
351 +programs whose distribution conditions are different, write to the author
352 +to ask for permission.  For software which is copyrighted by the Free
353 +Software Foundation, write to the Free Software Foundation; we sometimes
354 +make exceptions for this.  Our decision will be guided by the two goals
355 +of preserving the free status of all derivatives of our free software and
356 +of promoting the sharing and reuse of software generally.
357 +
358 +                           NO WARRANTY
359 +
360 +  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
361 +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
362 +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
363 +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
364 +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
365 +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
366 +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
367 +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
368 +REPAIR OR CORRECTION.
369 +
370 +  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
371 +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
372 +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
373 +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
374 +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
375 +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
376 +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
377 +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
378 +POSSIBILITY OF SUCH DAMAGES.
379 +
380 +                    END OF TERMS AND CONDITIONS
381 +\f
382 +           How to Apply These Terms to Your New Programs
383 +
384 +  If you develop a new program, and you want it to be of the greatest
385 +possible use to the public, the best way to achieve this is to make it
386 +free software which everyone can redistribute and change under these terms.
387 +
388 +  To do so, attach the following notices to the program.  It is safest
389 +to attach them to the start of each source file to most effectively
390 +convey the exclusion of warranty; and each file should have at least
391 +the "copyright" line and a pointer to where the full notice is found.
392 +
393 +    <one line to give the program's name and a brief idea of what it does.>
394 +    Copyright (C) <year>  <name of author>
395 +
396 +    This program is free software; you can redistribute it and/or modify
397 +    it under the terms of the GNU General Public License as published by
398 +    the Free Software Foundation; either version 2 of the License, or
399 +    (at your option) any later version.
400 +
401 +    This program is distributed in the hope that it will be useful,
402 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
403 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
404 +    GNU General Public License for more details.
405 +
406 +    You should have received a copy of the GNU General Public License
407 +    along with this program; if not, write to the Free Software
408 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
409 +
410 +
411 +Also add information on how to contact you by electronic and paper mail.
412 +
413 +If the program is interactive, make it output a short notice like this
414 +when it starts in an interactive mode:
415 +
416 +    Gnomovision version 69, Copyright (C) year  name of author
417 +    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
418 +    This is free software, and you are welcome to redistribute it
419 +    under certain conditions; type `show c' for details.
420 +
421 +The hypothetical commands `show w' and `show c' should show the appropriate
422 +parts of the General Public License.  Of course, the commands you use may
423 +be called something other than `show w' and `show c'; they could even be
424 +mouse-clicks or menu items--whatever suits your program.
425 +
426 +You should also get your employer (if you work as a programmer) or your
427 +school, if any, to sign a "copyright disclaimer" for the program, if
428 +necessary.  Here is a sample; alter the names:
429 +
430 +  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
431 +  `Gnomovision' (which makes passes at compilers) written by James Hacker.
432 +
433 +  <signature of Ty Coon>, 1 April 1989
434 +  Ty Coon, President of Vice
435 +
436 +This General Public License does not permit incorporating your program into
437 +proprietary programs.  If your program is a subroutine library, you may
438 +consider it more useful to permit linking proprietary applications with the
439 +library.  If this is what you want to do, use the GNU Library General
440 +Public License instead of this License.
441 Index: cgcs-users-1.0-r0/COPYRIGHT.orig
442 ===================================================================
443 --- /dev/null
444 +++ cgcs-users-1.0-r0/COPYRIGHT.orig
445 @@ -0,0 +1,17 @@
446 +This file is part of IBSH (Iron Bars Shell) , a restricted Unix shell
447 +Copyright (C) 2005  Attila Nagyidai
448 +
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.
453 +
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.
458 +
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.
462 +
463 Index: cgcs-users-1.0-r0/INSTALL.orig
464 ===================================================================
465 --- /dev/null
466 +++ cgcs-users-1.0-r0/INSTALL.orig
467 @@ -0,0 +1,23 @@
468 +Installing ibsh is really easy, so no need for the usual sections
469 +in this document. There is no configure script either, so if 
470 +something wrong, make will fail.
471 +
472 +# make ibsh
473 +# make ibsh_install
474 +
475 +Optionally:
476 +
477 +# make clean
478 +
479 +
480 +To uninstall ibsh:
481 +
482 +# make ibsh_uninstall
483 +
484 +
485 +Of course you will have to enable this shell by:
486 +# echo /bin/ibsh >> /etc/shells
487 +or however you like it.
488 +And make sure the permissions read 0755 !
489 +
490 +2005.03.24.
491 Index: cgcs-users-1.0-r0/main.c.orig
492 ===================================================================
493 --- /dev/null
494 +++ cgcs-users-1.0-r0/main.c.orig
495 @@ -0,0 +1,233 @@
496 +/*
497 +  Created: 03.19.05 11:34:57 by Attila Nagyidai
498 +
499 +  $Id: C\040Console.c,v 1.1.2.1 2003/08/13 00:38:46 neum Exp $
500 +
501 +  This file is part of IBSH (Iron Bars Shell) , a restricted Unix shell
502 +  Copyright (C) 2005  Attila Nagyidai
503 +
504 +  This program is free software; you can redistribute it and/or
505 +  modify it under the terms of the GNU General Public License
506 +  as published by the Free Software Foundation; either version 2
507 +  of the License, or (at your option) any later version.
508 +
509 +  This program is distributed in the hope that it will be useful,
510 +  but WITHOUT ANY WARRANTY; without even the implied warranty of
511 +  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
512 +  GNU General Public License for more details.
513 +
514 +  You should have received a copy of the GNU General Public License
515 +  along with this program; if not, write to the Free Software
516 +  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
517 +
518 +  Author: Attila Nagyidai
519 +  Email: na@ent.hu
520 +
521 +  Co-Author: Shy
522 +  Email: shy@cpan.org
523 +
524 +  Co-Author: Witzy
525 +  Email: stazzz@altern.org
526 +
527 +  URL: http://ibsh.sourceforge.net
528 +  IRC: irc.freenode.net #ibsh
529 +  RSS, Statistics, etc: http://sourceforge.net/projects/ibsh/
530 +
531 +*/
532 +
533 +/* Header files */
534 +#include "ibsh.h"
535 +
536 +/* Main: */
537 +/* Handle arguments, read config files, start command processing. */
538 +/* IBSH doesnt use any command line arguments, but my text editor */
539 +/* uses this code in all new c files to create. And i didnt have the */
540 +/* heart to remove it. ;p */
541 +/* Technical Description: */
542 +/* Get the passwd entry for the user. The uid is easily aquired, since */
543 +/* it is the real user id. After that, grab the passwd file entry upon */
544 +/* the id, and copy the information to the loggedin struct. */
545 +/* Add some signal handlers too. */
546 +/* The infinite loop: */
547 +/* Get the current directory, the full path. Compute the jailpath from that, */
548 +/* that is the directories below the users homedir, which is the jail root. */
549 +/* The jail ceiling if you like. Print some prompt to the user with the jailpath, */
550 +/* and read stdin for incoming commands. Filter out the bad commands, typos, the */
551 +/* not allowed commands. It the command is ok, execute it. If it is a shell builtin, */
552 +/* use our builtin code, otherwise use execve. After execve, check if the user didnt */
553 +/* use the last command to create some illegal content. If yes, erase that. Give the */
554 +/* notice only afterwards. */
555 +int main(int argc, char **argv)
556 +{
557 +    char temp[STRING_SIZE], *buf;
558 +    struct stat info;
559 +    uid_t ruid, euid;
560 +    gid_t rgid, egid;
561 +
562 +
563 +    /* setuid protection */
564 +    ruid = getuid();
565 +    euid = geteuid();
566 +    rgid = getgid();
567 +    egid = getegid();
568 +    if ( (ruid!=euid) || (ruid==0) || (euid==0) || (rgid!=egid) || (rgid==0) || (egid==0) ) {
569 +        OPENLOG;
570 +        syslog(LOG_ERR, "setuid/setgid violation!");
571 +        CLOSELOG;
572 +        printf("ibsh: setuid/setgid violation!! exiting...\n");
573 +#ifdef DEBUG
574 +        printf("ruid: %d;euid: %d;rgid: %d;egid: %d\n", ruid,euid,rgid,egid);
575 +#endif
576 +        exit(0);
577 +    }
578 +
579 +    /* To Do: The code of your application goes here */
580 +    /* First part: */
581 +    /* Get essential information about the user who got this shell: */
582 +    /* first the username, then the user id. Upon this, retrieve the */
583 +    /* user's record in the passwd file. */
584 +    bzero(&loggedin, sizeof(loggedin));
585 +    loggedin.uid = getuid();
586 +    loggedin.record = getpwuid(loggedin.uid);
587 +    if ( loggedin.record == NULL ) {
588 +        loggedin.record = getpwnam(loggedin.uname);
589 +        if ( loggedin.record == NULL ) {
590 +            openlog(loggedin.uname, LOG_PID, LOG_AUTH);
591 +            syslog(LOG_ERR, "Can not obtain user information");
592 +            printf("Can not obtain user information\n");
593 +            closelog();
594 +            exit(0);
595 +        }
596 +    }
597 +    strncpy(loggedin.uname, loggedin.record->pw_name, PAM_SIZE);
598 +    strncpy(loggedin.udir, loggedin.record->pw_dir, STRING_SIZE);
599 +
600 +    /* Second part: */
601 +    /* Handle some signal catching. Read the configuration files. */
602 +    signal( SIGINT, SIG_IGN );
603 +    signal( SIGQUIT, SIG_IGN );
604 +    signal( SIGTERM, SIG_IGN );
605 +    signal( SIGTSTP, SIG_IGN );
606 +    LoadConfig();
607 +
608 +    /* Command mode */
609 +    if(argc == 3) {
610 +        if ( argv[1][1] == 'c' ) {
611 +            if ( CommandOK(argv[2], loggedin.udir, "/", filtered_command) == 1) {
612 +                exitcode = hhsystem(filtered_command);
613 +                OPENLOG;
614 +                syslog(LOG_INFO, "command %s ordered, command %s has been executed.",
615 +                       argv[2], filtered_command);
616 +                printf("command %s ordered, command %s has been executed.\n",
617 +                       argv[2], filtered_command);
618 +                CLOSELOG;
619 +                exit(exitcode);
620 +            }
621 +            printf("CommandOK failed (%s/%s)\n", loggedin.udir, filtered_command);
622 +            exit(0);
623 +        }
624 +        else {
625 +            printf("Invalid are (%s)\n", argv[1]);
626 +            exit(0);
627 +        }
628 +    }
629 +
630 +    OPENLOG;
631 +    syslog(LOG_INFO, "user %s has logged in.", loggedin.uname);
632 +    CLOSELOG;
633 +
634 +
635 +#ifdef INCLUDE_DELETE_BAD_FILES
636 +    DelBadFiles(loggedin.udir);
637 +#endif
638 +    if ( chdir (loggedin.udir) < 0 )
639 +        return -1;
640 +
641 +
642 +    /* Third part: */
643 +    /* Start reading and processing the user issued commands. */
644 +    /* Split the command by the spaces, filter out anything, */
645 +    /* that would allow the user to access files outside the */
646 +    /* jail. Filter out multiples and pipes as well. No program */
647 +    /* will be allowed to run, unless it is mentioned in the */
648 +    /* config files. Files that are created with an extension */
649 +    /* that is listed in the other config file, must be deleted! */
650 +    for ( ; ; ) {
651 +        /* Where is he ? */
652 +       if ( getcwd(real_path, STRING_SIZE) == NULL )
653 +           return -1;
654 +        GetPositionInJail(real_path, loggedin.udir, jail_path);
655 +        if ( (strlen(jail_path)) == 0 ) {
656 +            strncpy(jail_path, "/", 2);
657 +        }
658 +        /* We don't want the user to know where he actually is. */
659 +        /* This is the prompt! */
660 +        printf("[%s]%% ", jail_path);
661 +        /* scanf("%s", user_command); */
662 +        myscanf(user_command, real_path);
663 +        /* Command interpretation and execution. */
664 +        if ( (CommandOK(user_command, loggedin.udir, jail_path, filtered_command)) == 0 ) {
665 +            printf("Sorry, can't let you do that!\n");
666 +            log_attempt(loggedin.uname);  /* v0.2a */
667 +            continue;
668 +        }
669 +        /* If the user issued command starts with a shell builtin. */
670 +        bzero(temp, strlen(temp));
671 +        if ( (buf = strstr(filtered_command, "cd")) != NULL ) {
672 +            if ( (strcmp(buf, filtered_command)) == 0 ) {
673 +                LTrim3(filtered_command, temp);
674 +                if ( (strcmp(temp, real_path)) != 0 ) {
675 +                    if ( (strcmp(temp, "..")) == 0 ) {
676 +                        PathMinusOne(jail_path, temp, 1,sizeof(temp));
677 +                    }
678 +                    if ( (strcmp(temp, "/")) == 0 ) {
679 +                        strncpy(temp, loggedin.udir, LINE_SIZE);
680 +                    }
681 +                    exitcode = chdir(temp);
682 +                    if ( exitcode == -1 ) {
683 +                        printf("ibsh: cd: %s: No such file or directory\n", temp);
684 +                    }
685 +                }
686 +                continue;
687 +            }
688 +        }
689 +        else if ( (buf = strstr(filtered_command, "pwd")) != NULL ) {
690 +            if ( (strcmp(buf, filtered_command)) == 0 ) {
691 +                printf("%s\n", jail_path);
692 +                continue;
693 +            }
694 +        }
695 +        else if ( (buf = strstr(filtered_command, "logout")) != NULL ) {
696 +            if ( (strcmp(buf, filtered_command)) == 0 ) {
697 +                OPENLOG;
698 +                syslog(LOG_INFO, "user %s has logged out.", loggedin.uname);
699 +                CLOSELOG;
700 +                break;
701 +            }
702 +        }
703 +        else if ( (buf = strstr(filtered_command, "exit")) != NULL ) {
704 +            if ( (strcmp(buf, filtered_command)) == 0 ) {
705 +                OPENLOG;
706 +                syslog(LOG_INFO, "user %s has logged out.", loggedin.uname);
707 +                printf("user %s has logged out\n", loggedin.uname);
708 +                CLOSELOG;
709 +                break;
710 +            }
711 +        }
712 +        else {
713 +            exitcode = hhsystem(filtered_command);
714 +            if ( exitcode < 0 ) {
715 +                printf("%s\n", strerror(errno));
716 +            }
717 +        }
718 +        if ( getcwd(real_path, STRING_SIZE) == NULL ) 
719 +            return -1;
720 +#ifdef INCLUDE_BAD_FILES
721 +        DelBadFiles(loggedin.udir);
722 +#endif
723 +        if ( chdir (real_path) < 0 )
724 +            return 1;
725 +    }
726 +    return 0;
727 +}
728 +
729 Index: cgcs-users-1.0-r0/Makefile.orig
730 ===================================================================
731 --- /dev/null
732 +++ cgcs-users-1.0-r0/Makefile.orig
733 @@ -0,0 +1,56 @@
734 +# This is the makefile for ibsh 0.3e
735 +CC = gcc -g -O3
736 +OBJECTS = main.o command.o jail.o execute.o config.o misc.o antixploit.o delbadfiles.o
737 +
738 +all ibsh: ${OBJECTS} ibsh.h
739 +       ${CC} -o ibsh ${OBJECTS}
740 +
741 +main.o: main.c ibsh.h
742 +       ${CC} -c main.c
743 +
744 +command.o: command.c ibsh.h
745 +       ${CC} -c command.c
746 +
747 +jail.o: jail.c ibsh.h
748 +       ${CC} -c jail.c
749 +
750 +execute.o: execute.c ibsh.h
751 +       ${CC} -c execute.c
752 +
753 +config.o: config.c ibsh.h
754 +       ${CC} -c config.c
755 +
756 +misc.o: misc.c ibsh.h
757 +       ${CC} -c misc.c
758 +
759 +antixploit.o: antixploit.c ibsh.h
760 +       ${CC} -c antixploit.c
761 +
762 +delbadfiles.o: delbadfiles.c ibsh.h
763 +       ${CC} -c delbadfiles.c
764 +
765 +ibsh_install:
766 +       cp ./ibsh /bin/
767 +       mkdir /etc/ibsh
768 +       mkdir /etc/ibsh/cmds
769 +       mkdir /etc/ibsh/xtns
770 +       cp ./globals.cmds /etc/ibsh/
771 +       cp ./globals.xtns /etc/ibsh/
772 +
773 +ibsh_uninstall:
774 +       rm -rf /etc/ibsh/globals.cmds
775 +       rm -rf /etc/ibsh/globals.xtns
776 +       rm -rf /etc/ibsh/cmds/*.*
777 +       rm -rf /etc/ibsh/xtns/*.*
778 +       rmdir /etc/ibsh/cmds
779 +       rmdir /etc/ibsh/xtns
780 +       rmdir /etc/ibsh
781 +       rm -rf /bin/ibsh
782 +
783 +clean:
784 +       rm -rf ibsh
785 +       rm -rf *.o
786 +
787 +
788 +# 13:49 2005.04.06.
789 +
790 Index: cgcs-users-1.0-r0/README.orig
791 ===================================================================
792 --- /dev/null
793 +++ cgcs-users-1.0-r0/README.orig
794 @@ -0,0 +1,29 @@
795 +       Iron Bars SHell - a restricted interactive shell.
796 +
797 +Overview
798 +
799 +       For long i have been in the search of a decent restricted shell, but in vain.
800 +       The few i found, were really easy to hack, and there were quite a few docs
801 +       around on the web about hacking restricted shells with a menu interface.
802 +       For my definitions, a restricted shell must not only prevent the user to 
803 +       escape her jail, but also not to access any files outside the jail.
804 +       The system administrator must have total control over the restricted shell.
805 +       These are the major features incorporated and realized by ibsh.
806 +
807 +
808 +Features
809 +
810 +       Please read the changelog.      
811 +
812 +
813 +Installation
814 +
815 +       Read the INSTALL file.
816 +
817 +
818 +Contact
819 +       See Authors file.
820 +
821 +
822 +Attila Nagyidai
823 +2005.05.23.
824 Index: cgcs-users-1.0-r0/Release.orig
825 ===================================================================
826 --- /dev/null
827 +++ cgcs-users-1.0-r0/Release.orig
828 @@ -0,0 +1,17 @@
829 +This release introduces minor bugfixes, and important new and renewed features.
830 +Erasing evil files in the home directory of the user is incorporated again, with 
831 +many improvements. First of all: no file will be erased! Only the access to them
832 +will be blocked. The extension policy has changed, now ibsh blocks those extensions,
833 +that are NOT listed. This goes in sync with the usual method of operation of ibsh.
834 +The execute permission of files in the user space, will be removed.
835 +New customizing features were added: each user now can have her own commands and 
836 +extensions file, created and maintained by the system administrator. Some users
837 +(employees) may require access to special programs. User configuration files allow
838 +this access only those, who need it, not for everybody.
839 +Ibsh now scans not only the extensions of files, but the content too! Whatever the permission
840 +for a certain file exists, if that contains source code, or is a linux binary, access
841 +will be blocked.
842 +The absolute path for the users is now limited to 255 characters. Longer, already
843 +existing filenames will be renamed.
844 +
845 +06/04/2005 
846 Index: cgcs-users-1.0-r0/TODO.orig
847 ===================================================================
848 --- /dev/null
849 +++ cgcs-users-1.0-r0/TODO.orig
850 @@ -0,0 +1,10 @@
851 +TODO
852 +
853 +       - tab completion.
854 +       - shell variables.
855 +       - some changes to the prompt, maybe variable prompt.
856 +       - history
857 +       - to be able to use corporate, or other large/complicated programs in a safe
858 +       working environment, yet be able to share files/work with others.
859 +
860 +2005.05.23.