︙ | | |
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
fprintf(stderr, "Tcl Error is: %s\n", Tcl_GetStringResult(interp));
Tcl_DeleteInterp(interp);
return(NULL);
}
Tcl_HideCommand(interp, "glob", "glob");
Tcl_HideCommand(interp, "exec", "exec");
Tcl_HideCommand(interp, "pid", "pid");
Tcl_HideCommand(interp, "auto_load_index", "auto_load_index");
Tcl_HideCommand(interp, "unknown", "unknown");
Tcl_HideCommand(interp, "auto_load_index", "auto_load_index");
Tcl_HideCommand(interp, "unknown", "unknown");
return(interp);
}
static Tcl_Interp *appfs_TclInterp(void) {
Tcl_Interp *interp;
interp = pthread_getspecific(interpKey);
if (interp == NULL) {
interp = appfs_create_TclInterp();
if (interp == NULL) {
return(NULL);
}
pthread_setspecific(interpKey, interp);
}
return(interp);
}
static int appfs_Tcl_Eval(Tcl_Interp *interp, int objc, const char *cmd, ...) {
Tcl_Obj **objv;
const char *arg;
|
︙ | | |
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
|
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
|
-
-
-
+
-
-
-
+
+
-
-
-
-
-
-
+
-
-
-
+
+
-
-
-
-
-
-
+
-
-
-
+
+
-
-
-
+
+
|
static void appfs_update_index(const char *hostname) {
Tcl_Interp *interp;
int tcl_ret;
APPFS_DEBUG("Enter: hostname = %s", hostname);
interp = pthread_getspecific(interpKey);
if (interp == NULL) {
interp = appfs_create_TclInterp();
interp = appfs_TclInterp();
if (interp == NULL) {
return;
if (interp == NULL) {
return;
}
pthread_setspecific(interpKey, interp);
}
tcl_ret = appfs_Tcl_Eval(interp, 2, "::appfs::getindex", hostname);
if (tcl_ret != TCL_OK) {
APPFS_DEBUG("Call to ::appfs::getindex failed: %s", Tcl_GetStringResult(interp));
return;
}
return;
}
static const char *appfs_getfile(const char *hostname, const char *sha1) {
Tcl_Interp *interp;
char *retval;
int tcl_ret;
interp = pthread_getspecific(interpKey);
if (interp == NULL) {
interp = appfs_create_TclInterp();
interp = appfs_TclInterp();
if (interp == NULL) {
return(NULL);
if (interp == NULL) {
return(NULL);
}
pthread_setspecific(interpKey, interp);
}
tcl_ret = appfs_Tcl_Eval(interp, 3, "::appfs::download", hostname, sha1);
if (tcl_ret != TCL_OK) {
APPFS_DEBUG("Call to ::appfs::download failed: %s", Tcl_GetStringResult(interp));
return(NULL);
}
retval = strdup(Tcl_GetStringResult(interp));
return(retval);
}
static void appfs_update_manifest(const char *hostname, const char *sha1) {
Tcl_Interp *interp;
int tcl_ret;
interp = pthread_getspecific(interpKey);
if (interp == NULL) {
interp = appfs_create_TclInterp();
interp = appfs_TclInterp();
if (interp == NULL) {
return;
if (interp == NULL) {
return;
}
pthread_setspecific(interpKey, interp);
}
tcl_ret = appfs_Tcl_Eval(interp, 3, "::appfs::getpkgmanifest", hostname, sha1);
if (tcl_ret != TCL_OK) {
APPFS_DEBUG("Call to ::appfs::getpkgmanifest failed: %s", Tcl_GetStringResult(interp));
return;
}
return;
}
static uid_t appfs_get_fsuid(void) {
struct fuse_context *ctx;
ctx = fuse_get_context();
if (ctx == NULL) {
/* Unable to lookup user for some reason */
/* Return an unprivileged user ID */
return(1);
}
return(ctx->uid);
}
static char *appfs_get_homedir(uid_t fsuid) {
|
︙ | | |
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
|
347
348
349
350
351
352
353
354
355
356
357
358
359
360
|
-
-
-
-
-
-
-
-
-
|
Tcl_SetObjResult(interp, Tcl_NewStringObj(homedir, -1));
free(homedir);
return(TCL_OK);
}
static struct appfs_children *appfs_getchildren(const char *hostname, const char *package_hash, const char *path, int *children_count_p) {
}
static char *appfs_lookup_package_hash(const char *hostname, const char *package, const char *os, const char *cpuArch, const char *version) {
}
static int appfs_getfileinfo(const char *hostname, const char *package_hash, const char *_path, struct appfs_pathinfo *pathinfo) {
}
/* Generate an inode for a given path */
static long long appfs_get_path_inode(const char *path) {
long long retval;
const char *p;
retval = 10;
|
︙ | | |
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
|
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
|
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
if (tcl_ret != TCL_OK) {
fprintf(stderr, "[error] %s\n", sql_ret);
return(1);
}
if (sql_ret && sql_ret[0] != '\0') {
printf("%s\n", sql_ret);
printf("%s\n", sql_ret);
}
return(0);
}
static int appfs_tcl(const char *tcl) {
Tcl_Interp *interp;
const char *tcl_result;
int tcl_ret;
interp = appfs_create_TclInterp();
if (interp == NULL) {
fprintf(stderr, "Unable to create a Tcl interpreter. Aborting.\n");
return(1);
}
tcl_ret = Tcl_Eval(interp, tcl);
tcl_result = Tcl_GetStringResult(interp);
if (tcl_ret != TCL_OK) {
fprintf(stderr, "[error] %s\n", tcl_result);
return(1);
}
if (tcl_result && tcl_result[0] != '\0') {
printf("%s\n", tcl_result);
}
return(0);
}
static int Appfsd_Init(Tcl_Interp *interp) {
#ifdef USE_TCL_STUBS
if (Tcl_InitStubs(interp, TCL_VERSION, 0) == 0L) {
|
︙ | | |
624
625
626
627
628
629
630
631
632
633
634
|
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
|
+
+
+
+
|
return(1);
}
if (argc == 3 && strcmp(argv[1], "-sqlite3") == 0) {
return(appfs_sqlite3(argv[2]));
}
if (argc == 3 && strcmp(argv[1], "-tcl") == 0) {
return(appfs_tcl(argv[2]));
}
return(fuse_main(argc, argv, &appfs_oper, NULL));
}
|