Check-in [6f341b0c52]
Overview
SHA1:6f341b0c52d4253e3bee946c6cb6424a66882f66
Date: 2017-01-10 21:22:12
User: rkeene
Comment:Implemented "setuid"
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:23
[59157f7f93] Fixed "setuid" to not return in failure when it succeeds (user: rkeene, tags: trunk)
21:22
[6f341b0c52] Implemented "setuid" (user: rkeene, tags: trunk)
21:18
[268ce6158e] Implemented "getuid" (user: rkeene, tags: trunk)
Changes

Modified tuapi.c from [9641ecfb8b] to [1d22e5c805].

   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    645   static int tuapi_setuid(ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
   646         -	Tcl_SetObjResult(interp, Tcl_NewStringObj("not implemented", -1));
          646  +	Tcl_WideInt tclUid;
          647  +	uid_t uid;
          648  +	int chk_ret;
          649  +
          650  +	if (objc != 2) {
          651  +		Tcl_SetObjResult(interp, Tcl_NewStringObj("wrong # args: should be \"::tuapi::syscall::setuid uid\"", -1));
          652  +	}
          653  +
          654  +	chk_ret = Tcl_GetWideIntFromObj(interp, objv[1], &tclUid);
          655  +	if (chk_ret != TCL_OK) {
          656  +		return(chk_ret);
          657  +	}
          658  +
          659  +	uid = tclUid;
          660  +
          661  +	chk_ret = setuid(uid);
          662  +	if (chk_ret != 0) {
          663  +		Tcl_SetObjResult(interp, Tcl_NewStringObj("setuid failed", -1));
          664  +
          665  +		return(TCL_ERROR);
          666  +	}
          667  +
          668  +	Tcl_SetObjResult(interp, Tcl_NewStringObj("", -1));
   647    669   
   648    670   	return(TCL_ERROR);
   649    671   }
   650    672   
   651    673   static int tuapi_getuid(ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
   652    674   	uid_t uid;
   653    675   	Tcl_WideInt tclUid;