460
461
462
463
464
465
466
467
468
469
470
471
472
473
|
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
}
static int tcl_appfs_simulate_user_fs_leave(ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
appfs_simulate_user_fs_leave();
return(TCL_OK);
}
static int tcl_appfs_get_fsuid(ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
uid_t fsuid;
fsuid = appfs_get_fsuid();
Tcl_SetObjResult(interp, Tcl_NewWideIntObj(fsuid));
return(TCL_OK);
}
static int tcl_appfs_get_fsgid(ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
gid_t fsgid;
fsgid = appfs_get_fsgid();
Tcl_SetObjResult(interp, Tcl_NewWideIntObj(fsgid));
return(TCL_OK);
}
/*
* Generate an inode for a given path. The inode should be computed in such
* a way that it is unlikely to be duplicated and remains the same for a given
* file
*/
static long long appfs_get_path_inode(const char *path) {
|
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
|
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
|
-
-
+
+
|
memset(stbuf, 0, sizeof(struct stat));
stbuf->st_mtime = pathinfo.time;
stbuf->st_ctime = pathinfo.time;
stbuf->st_atime = pathinfo.time;
stbuf->st_ino = pathinfo.inode;
stbuf->st_mode = 0;
stbuf->st_uid = appfs_get_fsuid();
stbuf->st_gid = appfs_get_fsgid();
stbuf->st_uid = 0;
stbuf->st_gid = 0;
switch (pathinfo.type) {
case APPFS_PATHTYPE_DIRECTORY:
stbuf->st_mode = S_IFDIR | 0555;
stbuf->st_nlink = 2 + pathinfo.typeinfo.dir.childcount;
break;
case APPFS_PATHTYPE_FILE:
|
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
|
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
|
+
+
|
#ifdef USE_TCL_STUBS
if (Tcl_InitStubs(interp, TCL_VERSION, 0) == 0L) {
return(TCL_ERROR);
}
#endif
Tcl_CreateObjCommand(interp, "appfsd::get_homedir", tcl_appfs_get_homedir, NULL, NULL);
Tcl_CreateObjCommand(interp, "appfsd::get_fsuid", tcl_appfs_get_fsuid, NULL, NULL);
Tcl_CreateObjCommand(interp, "appfsd::get_fsgid", tcl_appfs_get_fsgid, NULL, NULL);
Tcl_CreateObjCommand(interp, "appfsd::simulate_user_fs_enter", tcl_appfs_simulate_user_fs_enter, NULL, NULL);
Tcl_CreateObjCommand(interp, "appfsd::simulate_user_fs_leave", tcl_appfs_simulate_user_fs_leave, NULL, NULL);
Tcl_PkgProvide(interp, "appfsd", "1.0");
return(TCL_OK);
}
|