[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ipcop-cvs
Subject:    [IPCop-cvs] ipcop/src/misc-progs installpackage.c, 1.3.2.10,
From:       Gilles Espinasse <gespinasse () users ! sourceforge ! net>
Date:       2007-10-21 22:42:15
Message-ID: E1IjjUy-000109-Fd () mail ! sourceforge ! net
[Download RAW message or body]

Update of /cvsroot/ipcop/ipcop/src/misc-progs
In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv17120/src/misc-progs

Modified Files:
      Tag: IPCOP_v1_4_0
	installpackage.c 
Log Message:
Suppress the cgi script number from the uploaded file.
Since we use gpg to sign the packet, we do not need an unpredictable name.

Without the number, it is far easier to remove the update file from
exithandler.
Need to move the call to atexit earlier to catch that case.
Make stbuf global to make it usable on exithandler

This could allow too to read information file before applying the update.
That's to late to be able to read that file after installation (particulary
 on rc release)

Define the update file as patch.tgz.gpg.
tgz is because the supplied update file is named this way.



Index: installpackage.c
===================================================================
RCS file: /cvsroot/ipcop/ipcop/src/misc-progs/installpackage.c,v
retrieving revision 1.3.2.10
retrieving revision 1.3.2.11
diff -C2 -d -r1.3.2.10 -r1.3.2.11
*** installpackage.c	21 Oct 2007 15:19:31 -0000	1.3.2.10
--- installpackage.c	21 Oct 2007 22:42:13 -0000	1.3.2.11
***************
*** 41,44 ****
--- 41,46 ----
  #define MINIMUMSPACE 500 * 1000
  
+ #define GPGFILE "/var/patches/patch.tgz.gpg"
+ 
  /* The lines in the package information file and the patches/installed list
   * are often longer than STRING_SIZE so we use a larger buffer */
***************
*** 48,54 ****
--- 50,60 ----
  FILE *infofile = NULL;
  char command[STRING_SIZE], tmpdir[] = "/var/log/pat_install_XXXXXX";
+ struct stat stbuf;
  
  void exithandler(void)
  {
+ 	/* remove GPGFILE if abort due to low available space */
+ 	if (!lstat( GPGFILE,&stbuf)) unlink( GPGFILE);
+ 
  	if(info) free(info);
  	if(infofile)
***************
*** 70,74 ****
  	int lowspace=0;
  	FILE *p;
- 	struct stat stbuf;
  	struct statvfs statvfsbuf;
  	double spaceavailable;
--- 76,79 ----
***************
*** 77,97 ****
  		exit(1);
  
! 	/* Sanitize arguments */
! 	if (argc < 2)
! 	{
! 		fprintf(stderr, "Missing arg\n");
! 		exit(1);
! 	}
! 	if (strspn(argv[1], NUMBERS) != strlen(argv[1]))
! 	{
! 		fprintf(stderr, "Bad arg\n");
! 		exit(1);
! 	}
  
  	/* read size of the patch file */
! 	snprintf(command, STRING_SIZE-1, "/var/patches/patch-%s.tar.gz.gpg", argv[1]);
! 	if (lstat(command,&stbuf)) {
! 		snprintf(command, STRING_SIZE-1, "Unable to stat /var/patches/patch-%s.tar.gz.gpg\n", argv[1]);
! 		fprintf(stderr, command);
  		exit(ERR_ANY);
  	}
--- 82,91 ----
  		exit(1);
  
! 	/* now exithandler will have something to erase */ 
! 	atexit(exithandler);
  
  	/* read size of the patch file */
! 	if (lstat( GPGFILE,&stbuf)) {
! 		fprintf(stderr, "Unable to stat " GPGFILE "\n");
  		exit(ERR_ANY);
  	}
***************
*** 141,146 ****
  		exit(ERR_TMPDIR);
  	}
- 	/* now exithandler will have something to erase */ 
- 	atexit(exithandler);
  
  	/* verify and extract package */
--- 135,138 ----
***************
*** 148,153 ****
  	snprintf(command, STRING_SIZE-1,
  		"/usr/bin/gpg --batch --homedir /root/.gnupg "
! 		"-o %s/patch-%s.tar.gz --decrypt /var/patches/patch-%s.tar.gz.gpg",
! 		tmpdir, argv[1], argv[1]);
  	ret = safe_system(command) >> 8;
  	if(ret==1) {
--- 140,144 ----
  	snprintf(command, STRING_SIZE-1,
  		"/usr/bin/gpg --batch --homedir /root/.gnupg "
! 		"-o %s/patch-1.tgz --decrypt " GPGFILE, tmpdir);
  	ret = safe_system(command) >> 8;
  	if(ret==1) {
***************
*** 162,167 ****
  	}
  	/* gpg signed package is no more needed, free that space */
! 	snprintf(command, STRING_SIZE-1, "/var/patches/patch-%s.tar.gz.gpg", argv[1]);
! 	unlink ( command );
  	sync();
  
--- 153,157 ----
  	}
  	/* gpg signed package is no more needed, free that space */
! 	unlink( GPGFILE );
  	sync();
  
***************
*** 169,173 ****
  	chdir (tmpdir);
  	snprintf(command, STRING_SIZE-1,
! 		"/bin/tar xzf %s/patch-%s.tar.gz", tmpdir, argv[1]);
  	if(safe_system(command)) {
  		fprintf(stderr, "Invalid package: untar failed\n");
--- 159,163 ----
  	chdir (tmpdir);
  	snprintf(command, STRING_SIZE-1,
! 		"/bin/tar xzf %s/patch-1.tgz", tmpdir);
  	if(safe_system(command)) {
  		fprintf(stderr, "Invalid package: untar failed\n");
***************
*** 175,180 ****
  	}
  
! 	/* patch-%s is no more needed, free that space */
! 	snprintf(command, STRING_SIZE-1, "%s/patch-%s.tar.gz", tmpdir, argv[1]);
  	unlink( command );
  	sync();
--- 165,170 ----
  	}
  
! 	/* patch-1 is no more needed, free that space */
! 	snprintf(command, STRING_SIZE-1, "%s/patch-1.tgz", tmpdir);
  	unlink( command );
  	sync();


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
IPCop-cvs mailing list
IPCop-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ipcop-cvs
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic