Check-in [268ce6158e]
Overview
SHA1:268ce6158e1d7c9d7488125ae20f670032bcf74f
Date: 2017-01-10 21:18:26
User: rkeene
Comment:Implemented "getuid"
Timelines: family | ancestors | descendants | both | trunk
Downloads: Tarball | ZIP archive
Other Links: files | file ages | folders | manifest
Tags And Properties
Context
2017-01-10
21:22
[6f341b0c52] Implemented "setuid" (user: rkeene, tags: trunk)
21:18
[268ce6158e] Implemented "getuid" (user: rkeene, tags: trunk)
2016-09-28
15:22
[3c20b13b52] Added license (MIT) (user: rkeene, tags: trunk)
Changes

Modified tuapi.c from [c4f2028e1f] to [9641ecfb8b].

   638    638   
   639    639   static int tuapi_mknod(ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
   640    640   	Tcl_SetObjResult(interp, Tcl_NewStringObj("not implemented", -1));
   641    641   
   642    642   	return(TCL_ERROR);
   643    643   }
   644    644   
   645         -static int tuapi_getuid(ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
          645  +static int tuapi_setuid(ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
   646    646   	Tcl_SetObjResult(interp, Tcl_NewStringObj("not implemented", -1));
   647    647   
   648    648   	return(TCL_ERROR);
   649    649   }
          650  +
          651  +static int tuapi_getuid(ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
          652  +	uid_t uid;
          653  +	Tcl_WideInt tclUid;
          654  +
          655  +	if (objc != 1) {
          656  +		Tcl_SetObjResult(interp, Tcl_NewStringObj("wrong # args: should be \"::tuapi::syscall::getuid\"", -1));
          657  +
          658  +		return(TCL_ERROR);
          659  +	}
          660  +
          661  +	uid = getuid();
          662  +	tclUid = uid;
          663  +
          664  +	Tcl_SetObjResult(interp, Tcl_NewWideIntObj(tclUid));
          665  +
          666  +	return(TCL_OK);
          667  +}
   650    668   
   651    669   static int tuapi_kill(ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
   652    670   	Tcl_Obj *signal_obj;
   653    671   
   654    672   	Tcl_WideInt pid_wide, sig_wide;
   655    673   	pid_t pid;
   656    674   	int sig;
................................................................................
  3154   3172   	Tcl_CreateObjCommand(interp, "::tuapi::syscall::mount", tuapi_mount, NULL, NULL);
  3155   3173   	Tcl_CreateObjCommand(interp, "::tuapi::syscall::umount", tuapi_umount, NULL, NULL);
  3156   3174   	Tcl_CreateObjCommand(interp, "::tuapi::syscall::swapon", tuapi_swapon, NULL, NULL);
  3157   3175   	Tcl_CreateObjCommand(interp, "::tuapi::syscall::swapoff", tuapi_swapoff, NULL, NULL);
  3158   3176   	Tcl_CreateObjCommand(interp, "::tuapi::syscall::mknod", tuapi_mknod, NULL, NULL);
  3159   3177   
  3160   3178   	/* Process related commands */
         3179  +	Tcl_CreateObjCommand(interp, "::tuapi::syscall::setuid", tuapi_setuid, NULL, NULL);
  3161   3180   	Tcl_CreateObjCommand(interp, "::tuapi::syscall::getuid", tuapi_getuid, NULL, NULL);
  3162   3181   	Tcl_CreateObjCommand(interp, "::tuapi::syscall::chroot", tuapi_chroot, NULL, NULL);
  3163   3182   	Tcl_CreateObjCommand(interp, "::tuapi::syscall::pivot_root", tuapi_pivot_root, NULL, NULL);
  3164   3183   	Tcl_CreateObjCommand(interp, "::tuapi::syscall::kill", tuapi_kill, NULL, NULL);
  3165   3184   	Tcl_CreateObjCommand(interp, "::tuapi::syscall::waitpid", tuapi_waitpid, NULL, NULL);
  3166   3185   	Tcl_CreateObjCommand(interp, "::tuapi::syscall::ps", tuapi_ps, NULL, NULL);
  3167   3186   	Tcl_CreateObjCommand(interp, "::tuapi::syscall::execve", tuapi_execve, NULL, NULL);