Check-in [152a83b125]
Overview
SHA1:152a83b1254f258846e8e89dcc3a636add604a97
Date: 2015-03-18 17:20:07
User: rkeene
Comment:Added basic support for removing the world/group permissions from files
Timelines: family | ancestors | descendants | both | trunk
Downloads: Tarball | ZIP archive
Other Links: files | file ages | folders | manifest
Tags And Properties
Context
2015-03-18
17:21
[40785110e7] Updated to use an environment variable to determine if we should do a debug build (usually not) (user: rkeene, tags: trunk)
17:20
[152a83b125] Added basic support for removing the world/group permissions from files (user: rkeene, tags: trunk)
2015-03-16
15:36
[e3ddb480d5] Improved "appfs-mkfs" latest detection (user: rkeene, tags: trunk)
Changes

Modified Makefile from [6eec822d80] to [33e6f3a5ed].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
APPFS_VERSION  = 1.4
CC             = gcc
PKG_CONFIG     = pkg-config
FUSE_CFLAGS    = $(shell $(PKG_CONFIG) --cflags fuse)
CFLAGS_DEBUG   = -Wall -g3 -ggdb3 -DDEBUG=1 -UNDEBUG -O0 -DAPPFS_EXIT_PATH=1
CFLAGS_RELEASE = -Wall -UDEBUG -DNDEBUG=1 -O3
CFLAGS         += $(FUSE_CFLAGS) $(TCL_CFLAGS) $(CFLAGS_RELEASE)
LDFLAGS        += $(TCL_LDFLAGS)
FUSE_LIBS      = $(shell $(PKG_CONFIG) --libs fuse)
LIBS           += $(FUSE_LIBS) $(TCL_LIBS)
PREFIX         = /usr/local
prefix         = $(PREFIX)
exec_prefix    = $(prefix)
bindir         = $(exec_prefix)/bin






|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
APPFS_VERSION  = 1.4
CC             = gcc
PKG_CONFIG     = pkg-config
FUSE_CFLAGS    = $(shell $(PKG_CONFIG) --cflags fuse)
CFLAGS_DEBUG   = -Wall -g3 -ggdb3 -DDEBUG=1 -UNDEBUG -O0 -DAPPFS_EXIT_PATH=1
CFLAGS_RELEASE = -Wall -UDEBUG -DNDEBUG=1 -O3
CFLAGS         += $(FUSE_CFLAGS) $(TCL_CFLAGS) $(CFLAGS_DEBUG)
LDFLAGS        += $(TCL_LDFLAGS)
FUSE_LIBS      = $(shell $(PKG_CONFIG) --libs fuse)
LIBS           += $(FUSE_LIBS) $(TCL_LIBS)
PREFIX         = /usr/local
prefix         = $(PREFIX)
exec_prefix    = $(prefix)
bindir         = $(exec_prefix)/bin

Modified appfsd.c from [7c511aec25] to [3e9adabf49].

139
140
141
142
143
144
145


146
147
148
149
150
151
152
...
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
...
930
931
932
933
934
935
936


937
938
939
940
941
942
943
944
945
946
947
948

949

950











951
952
953
954
955
956
957
....
1180
1181
1182
1183
1184
1185
1186








1187
1188
1189

1190
1191
1192
1193
1194
1195
1196
	unsigned long long inode;
	union {
		struct {
			int childcount;
		} dir;
		struct {
			int executable;


			off_t size;
		} file;
		struct {
			off_t size;
			char source[256];
		} symlink;
	} typeinfo;
................................................................................
	return;
}

/* Get information about a path, and optionally list children */
static int appfs_get_path_info(const char *path, struct appfs_pathinfo *pathinfo) {
	Tcl_Interp *interp;
	Tcl_Obj *attrs_dict, *attr_value;
	const char *attr_value_str;
	Tcl_WideInt attr_value_wide;
	int attr_value_int;
	static __thread Tcl_Obj *attr_key_type = NULL, *attr_key_perms = NULL, *attr_key_size = NULL, *attr_key_time = NULL, *attr_key_source = NULL, *attr_key_childcount = NULL, *attr_key_packaged = NULL;
	int cache_ret;
	int tcl_ret;
	int retval;
	uid_t fsuid;
................................................................................
				}

				break;
			case 'f': /* file */
				pathinfo->type = APPFS_PATHTYPE_FILE;
				pathinfo->typeinfo.file.size = 0;
				pathinfo->typeinfo.file.executable = 0;



				Tcl_DictObjGet(interp, attrs_dict, attr_key_size, &attr_value);
				if (attr_value != NULL) {
					tcl_ret = Tcl_GetWideIntFromObj(NULL, attr_value, &attr_value_wide);
					if (tcl_ret == TCL_OK) {
						pathinfo->typeinfo.file.size = attr_value_wide;
					}
				}

				Tcl_DictObjGet(interp, attrs_dict, attr_key_perms, &attr_value);
				if (attr_value != NULL) {
					attr_value_str = Tcl_GetString(attr_value);

					if (attr_value_str[0] == 'x') {

						pathinfo->typeinfo.file.executable = 1;











					}
				}
				break;
			case 's': /* symlink */
				pathinfo->type = APPFS_PATHTYPE_SYMLINK;
				pathinfo->typeinfo.symlink.size = 0;
				pathinfo->typeinfo.symlink.source[0] = '\0';
................................................................................
			break;
		case APPFS_PATHTYPE_FILE:
			if (pathinfo.typeinfo.file.executable) {
				stbuf->st_mode = S_IFREG | 0555;
			} else {
				stbuf->st_mode = S_IFREG | 0444;
			}









			stbuf->st_nlink = 1;
			stbuf->st_size = pathinfo.typeinfo.file.size;

			break;
		case APPFS_PATHTYPE_SYMLINK:
			stbuf->st_mode = S_IFLNK | 0555;
			stbuf->st_nlink = 1;
			stbuf->st_size = pathinfo.typeinfo.symlink.size;
			break;
		case APPFS_PATHTYPE_SOCKET:







>
>







 







|







 







>
>












>
|
>
|
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>



>







139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
...
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
...
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
....
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
	unsigned long long inode;
	union {
		struct {
			int childcount;
		} dir;
		struct {
			int executable;
			int suid;
			int worldaccessible;
			off_t size;
		} file;
		struct {
			off_t size;
			char source[256];
		} symlink;
	} typeinfo;
................................................................................
	return;
}

/* Get information about a path, and optionally list children */
static int appfs_get_path_info(const char *path, struct appfs_pathinfo *pathinfo) {
	Tcl_Interp *interp;
	Tcl_Obj *attrs_dict, *attr_value;
	const char *attr_value_str, *attr_value_str_i;
	Tcl_WideInt attr_value_wide;
	int attr_value_int;
	static __thread Tcl_Obj *attr_key_type = NULL, *attr_key_perms = NULL, *attr_key_size = NULL, *attr_key_time = NULL, *attr_key_source = NULL, *attr_key_childcount = NULL, *attr_key_packaged = NULL;
	int cache_ret;
	int tcl_ret;
	int retval;
	uid_t fsuid;
................................................................................
				}

				break;
			case 'f': /* file */
				pathinfo->type = APPFS_PATHTYPE_FILE;
				pathinfo->typeinfo.file.size = 0;
				pathinfo->typeinfo.file.executable = 0;
				pathinfo->typeinfo.file.suid = 0;
				pathinfo->typeinfo.file.worldaccessible = 0;

				Tcl_DictObjGet(interp, attrs_dict, attr_key_size, &attr_value);
				if (attr_value != NULL) {
					tcl_ret = Tcl_GetWideIntFromObj(NULL, attr_value, &attr_value_wide);
					if (tcl_ret == TCL_OK) {
						pathinfo->typeinfo.file.size = attr_value_wide;
					}
				}

				Tcl_DictObjGet(interp, attrs_dict, attr_key_perms, &attr_value);
				if (attr_value != NULL) {
					attr_value_str = Tcl_GetString(attr_value);
					for (attr_value_str_i = &attr_value_str[0]; *attr_value_str_i != '\0'; attr_value_str_i++) {
						switch (*attr_value_str_i) {
							case 'x':
								pathinfo->typeinfo.file.executable = 1;

								break;
							case 'U':
								pathinfo->typeinfo.file.suid = 1;

								break;
							case '-':
								pathinfo->typeinfo.file.worldaccessible = 1;

								break;
						}
					}
				}
				break;
			case 's': /* symlink */
				pathinfo->type = APPFS_PATHTYPE_SYMLINK;
				pathinfo->typeinfo.symlink.size = 0;
				pathinfo->typeinfo.symlink.source[0] = '\0';
................................................................................
			break;
		case APPFS_PATHTYPE_FILE:
			if (pathinfo.typeinfo.file.executable) {
				stbuf->st_mode = S_IFREG | 0555;
			} else {
				stbuf->st_mode = S_IFREG | 0444;
			}

			if (pathinfo.typeinfo.file.suid) {
				stbuf->st_mode = S_IFREG | 04000;
			}

			if (pathinfo.typeinfo.file.worldaccessible) {
				stbuf->st_mode &= ~077;
			}

			stbuf->st_nlink = 1;
			stbuf->st_size = pathinfo.typeinfo.file.size;

			break;
		case APPFS_PATHTYPE_SYMLINK:
			stbuf->st_mode = S_IFLNK | 0555;
			stbuf->st_nlink = 1;
			stbuf->st_size = pathinfo.typeinfo.symlink.size;
			break;
		case APPFS_PATHTYPE_SOCKET:

Modified appfsd.tcl from [98d9d73f56] to [b01c545d08].

434
435
436
437
438
439
440




441

442
443
444
445
446
447
448
				switch -- $fileInfo(type) {
					"#manifestmetadata" {
						unset -nocomplain fileInfo
						continue
					}
					"file" {
						set fileInfo(size) [lindex $work 0]




						set fileInfo(perms) [lindex $work 1]

						set fileInfo(sha1) [lindex $work 2]

						set work [lrange $work 3 end]
					}
					"symlink" {
						set fileInfo(source) [lindex $work 0]
						set work [lrange $work 1 end]







>
>
>
>
|
>







434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
				switch -- $fileInfo(type) {
					"#manifestmetadata" {
						unset -nocomplain fileInfo
						continue
					}
					"file" {
						set fileInfo(size) [lindex $work 0]

						# We lower-case the permissions because upper-case permissions
						# should not be set remotely as they may influence the security
						# of the system.
						set fileInfo(perms) [string tolower [lindex $work 1]]

						set fileInfo(sha1) [lindex $work 2]

						set work [lrange $work 3 end]
					}
					"symlink" {
						set fileInfo(source) [lindex $work 0]
						set work [lrange $work 1 end]