summaryrefslogtreecommitdiffstats
path: root/sysif.h
Commit message (Collapse)AuthorAgeFilesLines
* Don't use sleep function in tail streams.Kaz Kylheku2016-05-231-0/+1
| | | | | | | | | | | | | | | Let's use our usleep_wrap function which uses nanosleep. The old sleep can interact with SIGALRM. * stream.c (tail_calc): Calculate microseconds instead of seconds. (sleep): Wrapper for Windows gone. (tail_strategy): Rename sec variable to usec. Use usleep_wrap instead of sleep. * sysif.c (usleep_wrap): Change to extern. * sysif.h (usleep_wrap): Declaration updated.
* New functions: at-exit-call and at-exit-do-not-call.Kaz Kylheku2016-05-181-0/+2
| | | | | | | | | | | | | | * sysif.c (at_exit_list): New static variable. (at_exit_call, at_exit_do_not_call): New functions. (at_exit_handler): New static function. (sysif_init): GC-protect at_exit_list. Register at_exit_handler with C atexit function. Register intrinsic functions at-exit-call and at-exit-do-not-call. * sysif.h (at_exit_call, at_exit_do_not_call): Registered. * txr.1: Documented.
* New --reexec option.Kaz Kylheku2016-05-051-0/+3
| | | | | | | | | | | | | | | | | This helps with setuid hash bang scripting on Mac OS, and other plaforms where the interpreter executed out of a hash bang script runs with orinary privilege, even if marked setuid. * sysif.c (exec_wrap): Static function turns extern. * sysif.h (exec-wrap): Declared. * txr.1: Documented --reexec. Added notes about setuid under Hash Bang Support. * txr.c (help): List --reexec option. (txr_main): Implement --reexec option.
* Implement setgid script support.Kaz Kylheku2016-05-021-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | TXR now notices that it's running setgid, and implements setgid logic for scripts. * sysif.c (orig_egid, real_gid, is_setgid): New static variables. (repress_privilege): Treat real and effective group ID similarly to user ID. Save them in global variables, and set the is_setgid flag. (drop_privilege): Drop setgid privilege similarly to setuid. Operate selectively: if neither setuid nor setgid is in effect, do nothing, but if just one is in effect, don't do anything for the other. (simulate_setuid): Function renamed to simulate_setuid_setgid. A small change is made here: if the fstat fails, just drop privilege, don't abort. Implement setgid operation independently of setuid. The is_setgid and is_setuid flags are manipulated here now to get the drop_privileges function to selectively drop setuid if we are running a script which is only segid, or drop setgid if we are running a setuid only script. * sysif.h (simulate_setuid): Declaration name change to simulate_setuid_setgid. * txr.c (txr_main): Follow rename of simulate_setuid. * txr.1: SETUID OPERATION section changed to SETUID/SETGID operation, and setgid description worked into the text.
* Expose stat_to_struct outside of sysif.Kaz Kylheku2016-04-151-0/+4
| | | | | | * sysif.c (stat_to_struct): Change to external linkage. * sysif.h (stat_to_struct): Declared.
* Missing return type on some inline functions.Kaz Kylheku2016-02-291-2/+2
| | | | | * sysif.h (repress_privilege, drop_privilege): Add missing void.
* Support setuid operation.Kaz Kylheku2016-01-231-0/+9
| | | | | | | | | | | | | | | | | | | | | * sysif.c (orig_euid, real_uid, repress_called, is_setuid): New static variables. (repress_privilege, drop_privilage, simulate_setuid): New functions. (RC_MAGIC): New preprocessor symbol. * sysif.c (repress_privilege, drop_privilage, simulate_setuid): Declared. * txr.c (txr_main): Call repress_privilege to check and remember whether we are in setuid mode, and temporarily drop the effective uid to the real one. (txr_main): Permanently drop privileges in all cases except script execution. In script execution cases, go through simulate_setuid to either set or preserve the effective user ID, or else drop privs. * txr.1: Documented setuid operation in new section.
* Copyright year bump.Kaz Kylheku2015-12-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | * LICENSE, METALICENSE, Makefile, args.c, args.h, arith.c, arith.h, cadr.c, cadr.h, combi.c, combi.h, configure, debug.c, debug.h, eval.c, eval.h, filter.c, filter.h, gc.c, gc.h, glob.c, glob.h, hash.c, hash.h, jmp.S, lib.c, lib.h, lisplib.c, lisplib.h, match.c, match.h, parser.c, parser.h, parser.l, parser.y, rand.c, rand.h, regex.c, regex.h, share/txr/stdlib/cadr.tl, share/txr/stdlib/except.tl, share/txr/stdlib/hash.tl, share/txr/stdlib/ifa.tl, share/txr/stdlib/path-test.tl, share/txr/stdlib/place.tl, share/txr/stdlib/struct.tl, share/txr/stdlib/txr-case.tl, share/txr/stdlib/type.tl, share/txr/stdlib/with-resources.tl, share/txr/stdlib/with-stream.tl, share/txr/stdlib/yield.tl, signal.c, signal.h, stream.c, stream.h, struct.c, struct.h, sysif.c, sysif.h, syslog.c, syslog.h, txr.1, txr.c, txr.h, unwind.c, unwind.h, utf8.c, utf8.h: Add 2016 copyright. * linenoise/LICENSE, linenoise/linenoise.c, linenoise/linenoise.h: Bump one principal author's copyright from 2014 to 2015. The code is based on a snapshot of 2015 upstream work.
* Large file support.Kaz Kylheku2015-12-041-0/+14
| | | | | | | | | | | | | | | | | | | | * stream.h (struct strm_ops): seek operation's second argument is now just a val. * stream.c (unimpl_seek, null_seek): Second argument is a val, not cnum, to conform with function pointer in stream structure. (stdio_seek): Accept offset as val, which could be a fixnum or bignum. Use new stdio_ftell and stdio_fseek functions so large values work. (seek_stream): No need to convert offset argument to cnum; pass the val directly to seek virtual function. * sysif.c (off_t_num, num_off_t, stdio_ftell, stdio_fseek): New functions. * sysif.h (OFF_T_MAX, OFF_T_MIN): New preprocessor symbols. (off_t_num, num_off_t, stdio_ftell, stdio_fseek): Declared.
* statf becomes external.Kaz Kylheku2015-09-231-0/+1
| | | | | | | | * sysif.c (statf): Linkage changed to external. Also, fixed wrong name being passed down to stat_impl. * sysif.h (statf): Declaration updated.
* Implement ~/.txr_profile mechanism.Kaz Kylheku2015-09-131-0/+1
| | | | | | | | | | | | * parser.c (load_rcfile): New function. (repl): Compute profile file name and try to load it before entering loop. * sysif.c (statp): Linkage becomes external. * sysif.h (statp): Declaration updated. * txr.1: Documented.
* Load and save repl history.Kaz Kylheku2015-09-071-0/+1
| | | | | | | | | | * parser.c (repl): If a HOME environment variable exists, then load the .txr_history file from the user's home directory and save it when exiting. * sysif.c (getenv_wrap): Static function changed to extern. * sysif.h (getenv_wrap): Declared.
* Move stat functions to use a struct.Kaz Kylheku2015-08-301-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lib.c (init): Move hash_init and struct init before sysif_init. * share/txr/stdlib/path-test.tl (sys:path-test-mode, path-mine-p, path-my-group-p, sys:path-access, path-newer, path-examine): Convert to struct return of stat functions. * stream.c (dev_k, ino_k, mode_k, nlink_k, uid_k, gid_k, rdev_k, size_k, blksize_k, blocks_k, atime_k, mtime_k, ctime_k): Global variable definitions removed from here. (stream_init): Initializations of moved global variables removed from here. * stream.h (dev_k, ino_k, mode_k, nlink_k, uid_k, gid_k, rdev_k, size_k, blksize_k, blocks_k, atime_k, mtime_k, ctime_k): Declarations removed from here. * sysif.c (stat_s, dev_s, ino_s, mode_s, nlink_s, uid_s, gid_s, rdev_s, size_s, blksize_s, blocks_s, atime_s, mtime_s, ctime_s): New global variables. (dev_k, ino_k, mode_k, nlink_k, uid_k, gid_k, rdev_k, size_k, blksize_k, blocks_k, atime_k, mtime_k, ctime_k): Existing variables moved here. (stat_to_struct): New static function. (stat_impl): Use stat_to_struct, except under 113 compatibility. (sysif_init): Initialize new symbol variables. Make stat struct type. * sysif.h (stat_s, dev_s, ino_s, mode_s, nlink_s, uid_s, gid_s, rdev_s, size_s, blksize_s, blocks_s, atime_s, mtime_s, ctime_s): Declared.
* Update copyright notices from 2014 to 2015.Kaz Kylheku2015-02-011-1/+1
| | | | | | | | | | | * arith.c, arith.h, combi.c, combi.h, debug.c, debug.h, eval.c, eval.h, filter.c, filter.h, gc.c, gc.h, hash.c, hash.h, lib.c, lib.h, match.c, match.h, parser.h, rand.c, rand.h, regex.c, regex.h, signal.c, signal.h, stream.c, stream.h, sysif.c, sysif.h, syslog.c, syslog.h, txr.c, txr.h, unwind.c, unwind.h, utf8.c, utf8.h: Update. * LICENSE, METALICENSE: Likewise.
* Moving system interface functions to separate module out ofKaz Kylheku2014-10-081-0/+27
the eval and stream modules. * Makefile (OBJS): Add sysif.o. * dep.mk: Regenerated. * eval.c (errno_wrap, daemon_wrap, exit_wrap, usleep_wrap, getpid_wrap, getppid_wrap, env_hash): Functions moved to sysif.c and changed to static functions. (eval_init): Registrations of functions moved to sysif.c. * lib.c (init): Call sysif_init. * stream.c (w_stat, statf, mkdir_wrap, chdir_wrap, getcwd_wrap, makedev_wrap, minor_wrap, major_wrap, mknod_wrap): Functions moved to sysif.c and become static functions. (stream_init): Registration of stat moved to sysif.c. (open_files, open_files_star): Bugfix: no longer erroneously included in #ifdef HAVE_UNISTD_H block. * stream.h (mkdir_wrap, chdir_wrap, getcwd_wrap, makedev_wrap, minor_wrap, major_wrap, mknod_wrap, symlink_wrap, link_wrap, readlink_wrap): Declarations removed. * sysif.c: New file. * sysif.h: New file.