[Commits] r670 - in trunk/daemon: debian src

new-commit at lists.openvcp.org new-commit at lists.openvcp.org
Sun May 24 15:13:39 UTC 2009


Author: cryptronic
Date: 2009-05-24 15:13:39 +0000 (Sun, 24 May 2009)
New Revision: 670

Modified:
   trunk/daemon/debian/postinst
   trunk/daemon/src/setup.c
   trunk/daemon/src/userbackup.c
Log:
little bugfixes


Modified: trunk/daemon/debian/postinst
===================================================================
--- trunk/daemon/debian/postinst	2009-05-24 11:52:08 UTC (rev 669)
+++ trunk/daemon/debian/postinst	2009-05-24 15:13:39 UTC (rev 670)
@@ -31,3 +31,5 @@
 	cat /etc/openvcpd.conf | sed "s#^IP=.*#IP=$IP#" | sed "s#^Password=.*#Password=$PASS#" | sed "s#^Ifaces=.*#Ifaces=$IFACES#" > $TEMPFILE
 	mv $TEMPFILE /etc/openvcpd.conf
 fi
+
+/etc/init.d/openvcpd start
\ No newline at end of file

Modified: trunk/daemon/src/setup.c
===================================================================
--- trunk/daemon/src/setup.c	2009-05-24 11:52:08 UTC (rev 669)
+++ trunk/daemon/src/setup.c	2009-05-24 15:13:39 UTC (rev 670)
@@ -41,14 +41,14 @@
 	memset(path2, 0, BUF_SIZE+1);
 
 	configdir = concat(global_settings.config_dir, "/", name, NULL);
-	
+
 	if(mkdir(configdir, 0755) == -1)
 	{
 		free(configdir);
 		return -1;
 	}
-	
-	/* Directorys */	
+
+	/* Directorys */
 	sconcat(path1, BUF_SIZE, configdir, "/interfaces", NULL);
 	mkdir(path1, 0755);
 
@@ -57,8 +57,8 @@
 
 	sconcat(path1, BUF_SIZE, configdir, "/name", NULL);
 	file_write(path1, name); file_attach(path1, "\n");
-	
 
+
 	/* Files */
 	xid = file_read(XID_COUNTER);
 
@@ -69,7 +69,7 @@
 
 		xid_int += 1;
 		free(xid);
-	
+
 		xid = (char *)malloc(BUF_SIZE+1);
 		snprintf(xid, BUF_SIZE, "%d", xid_int);
 		file_write(XID_COUNTER, xid);
@@ -80,8 +80,8 @@
 		file_write(XID_COUNTER, xid);
 	}
 
-		
 
+
 	sconcat(path1, BUF_SIZE, configdir, "/context", NULL);
 	file_write_many(path1, xid, "\n", NULL);
 	free(xid);
@@ -89,12 +89,12 @@
 
 	sconcat(path1, BUF_SIZE, configdir, "/fstab", NULL);
 	file_write(path1, "none /proc proc defaults 0 0\nnone /dev/pts devpts gid=5,mode=620 0 0\n");
-	
+
 	/* Symlinks */
 	sconcat(path1, BUF_SIZE, global_settings.run_dir, "/", name, NULL);
 	sconcat(path2, BUF_SIZE, configdir, "/run", NULL);
 	symlink(path1, path2);
-	
+
 	sconcat(path1, BUF_SIZE, global_settings.root_dir, "/", name, NULL);
 	sconcat(path2, BUF_SIZE, configdir, "/vdir", NULL);
 	symlink(path1, path2);
@@ -105,10 +105,10 @@
 
 
 
-		
+
 	free(configdir);
 
-	
+
 	return 1;
 }
 
@@ -116,17 +116,16 @@
 {
 	char path[BUF_SIZE+1];
 	char *context, *homedir, *imagedir, *backupdir;
-	char cachepath[BUF_SIZE]; 
+	char cachepath[BUF_SIZE];
 	char *tmpimagedir, *tmphomedir;
-	char *output = NULL;
 	int ret;
 	struct image_st image;
-	
+
 	memset(path, 0, BUF_SIZE+1);
 
 	if(name == NULL || dist == NULL)
 		return -1;
-		
+
 	backupdir = concat(global_settings.backup_dir, "/_", name, NULL);
 	imagedir = concat(global_settings.image_dir, "/", dist, NULL);
 	homedir = concat(global_settings.root_dir, "/", name, NULL);
@@ -142,26 +141,26 @@
 			dir_remove(cachepath);
 		}
 	}
-	
 
+
 	if(!dir_exist(imagedir))
 	{
 		free(backupdir);
 		free(imagedir);
-		free(homedir);	
-		
+		free(homedir);
+
 		return -1;
 	}
-		
 
+
 	if(dir_exist(homedir))
 	{
 
-		sconcat(path, BUF_SIZE, homedir, "/backup", NULL);	
-		
+		sconcat(path, BUF_SIZE, homedir, "/backup", NULL);
+
 		if(dir_exist(path))
 		{
-				
+
 			if(dir_exist(global_settings.backup_dir))
 			{
 				execb_cmd("mv", "mv", path, backupdir, NULL);
@@ -169,50 +168,50 @@
 		}
 
 		execb_cmd("rm", "rm", "-rf", homedir, NULL);
-	
+
 	}
-	
+
 	mkdir(homedir, 0755);
-	
+
 	tmpimagedir = concat(imagedir, "/.", NULL);
 	tmphomedir = concat(homedir, "/.", NULL);
 	execb_cmd("cp", "cp", "-a", tmpimagedir, tmphomedir, NULL);
 	free(tmpimagedir); free(tmphomedir);
-			
+
 	if(dir_exist(backupdir))
 	{
-		sconcat(path, BUF_SIZE, homedir, "/backup", NULL);	
+		sconcat(path, BUF_SIZE, homedir, "/backup", NULL);
 		execb_cmd("mv", "mv", backupdir, path, NULL);
 	}
-		
-	sconcat(path, BUF_SIZE, global_settings.config_dir, "/", name, "/context", NULL);	
-	context = file_read(path);	
+
+	sconcat(path, BUF_SIZE, global_settings.config_dir, "/", name, "/context", NULL);
+	context = file_read(path);
 	trim_string(context);
-	
+
 	if(fs_tagxid_support(homedir)) execb_cmd("chxid", "chxid", "-c",  context, "-R", homedir, NULL);
 
-		
+
 	free(context);
 
 
-	
-	
+
+
 	if(parse_image(dist, &image))
 	{
-		
+
 		if(image.name != NULL)
 		{
 			sconcat(path, BUF_SIZE, global_settings.config_dir, "/", name, "/image_name", NULL);
 			file_write_many(path, image.name, "\n", NULL);
 		}
-		
+
 		if(image.initstyle != NULL)
 		{
 			sconcat(path, BUF_SIZE, global_settings.config_dir, "/", name, "/apps", NULL);
 			if(!dir_exist(path)) mkdir(path, 0755);
 			sconcat(path, BUF_SIZE, global_settings.config_dir, "/", name, "/apps/init", NULL);
 			if(!dir_exist(path)) mkdir(path, 0755);
-		 
+
 		 	if(strcmp(image.initstyle, "plain") == 0
 		 		|| strcmp(image.initstyle, "gentoo") == 0 || strcmp(image.initstyle, "minit") == 0 )
 		 	{
@@ -220,18 +219,18 @@
 				file_write_many(path, image.initstyle, "\n", NULL);
 			}
 		}
-		
+
 		free_image(&image);
-	
+
 	}
   	else
-  	{                
+  	{
 		sconcat(path, BUF_SIZE, global_settings.config_dir, "/", name, "/image_name", NULL);
 		file_write_many(path, dist, "\n", NULL);
 	}
-		
-		
 
+
+
 	free(backupdir);
 	free(imagedir);
 	free(homedir);

Modified: trunk/daemon/src/userbackup.c
===================================================================
--- trunk/daemon/src/userbackup.c	2009-05-24 11:52:08 UTC (rev 669)
+++ trunk/daemon/src/userbackup.c	2009-05-24 15:13:39 UTC (rev 670)
@@ -38,11 +38,9 @@
 	struct ovcp_data_st *arg0;
 	struct ovcp_response_st *response;
 
-	char *name;
+	char *name, *size;
 	char filename[BUF_SIZE+1];
 
-	int fd;
-
 	arg0 = ovcp_request_get_arg(request, 0);
 	name = (char *)ovcp_data_get(arg0);
 
@@ -62,26 +60,29 @@
 		while((dir_entry = readdir(dir_ptr)) != NULL)
 		{
 
-			if(dir_entry->d_name[0] != '.' && dir_entry->d_name[(strlen(dir_entry->d_name)-6)] == '.')
+			if(strstr(dir_entry->d_name, name) != NULL)
 			{
-				ovcp_response_struct_new(response);
+				if(dir_entry->d_name[(strlen(dir_entry->d_name)-5)] != '.')
+				{
+					ovcp_response_struct_new(response);
 
-				if(strstr(dir_entry->d_name, name) != NULL)
 					ovcp_response_struct_add_string(response, "name", dir_entry->d_name);
 
-				//check whether file size file exists
-				sconcat(filename, BUF_SIZE, global_settings.userbackup_dir, "/", dir_entry->d_name, ".conf", NULL);
-				if(!file_exist(filename) && (fd = open(filename, O_RDONLY)) != -1)
-				{
-					line = file_readline(fd);
-					if (line != NULL)
+					//check whether file size file exists
+					sconcat(filename, BUF_SIZE, global_settings.userbackup_dir, "/", dir_entry->d_name, ".conf", NULL);
+					if(file_exist(filename))
 					{
-						trim_string(line);
-						ovcp_response_struct_add_string(response, "size", line);
-						free(line);
+						size = file_read(filename);
+						if (size != NULL)
+						{
+							trim_string(size);
+							ovcp_response_struct_add_string(response, "size", size);
+							free(size);
+						}
 					}
+
+					ovcp_response_struct_end(response);
 				}
-
 			}
 
 		}
@@ -98,7 +99,7 @@
 	struct ovcp_response_st *response;
 
 	char *name, *homedir, *userbackupdir, *backupname;
-	char *min, *hour, *day, *month, *year, *output;
+	char *min, *hour, *day, *month, *year, *output, *size;
 
 	char filename[BUF_SIZE+1];
 
@@ -166,8 +167,9 @@
 
 	if(output != NULL)
 	{
-		trim_string(output);
-		file_write_many(filename, output, "\n", NULL);
+		size = strtok(output, "\t");
+		trim_string(size);
+		file_write_many(filename, size, "\n", NULL);
 	}
 	else
 		file_write_many(filename, "unknown", "\n", NULL);
@@ -272,10 +274,8 @@
 	struct ovcp_response_st *response;
 
 	char *name, *homedir, *userbackupdir, *backupname;
-	char *backupnamenew, *userbackupdirnew, *output;
+	char *backupnamenew, *userbackupdirnew, *output, *filename, *size;
 
-	char filename[BUF_SIZE+1];
-
 	int ret=0;
 
 	arg0 = ovcp_request_get_arg(request, 0);
@@ -354,8 +354,9 @@
 
 	if(output != NULL)
 	{
-		trim_string(output);
-		file_write_many(filename, output, "\n", NULL);
+		size = strtok(output, "\t");
+		trim_string(size);
+		file_write_many(filename, size, "\n", NULL);
 	}
 	else
 		file_write_many(filename, "unknown", "\n", NULL);
@@ -371,6 +372,7 @@
 	free(backupnamenew);
 	free(homedir);
 	free(output);
+	free(filename);
 	return response;
 
 }



More information about the Commits mailing list