Browse files

sync parent

  • Loading branch information...
2 parents 706dbdf + e93c4d4 commit a1c25d5885e27a54d151eb9f287ff38f167da898 @grze grze committed Apr 20, 2011
View
6 clc/eucadmin/eucadmin/configfile.py
@@ -56,7 +56,7 @@ def __setitem__(self, key, value):
if self._save_to_file:
self._backup()
cmd_str = self.ChangeCmd % (key, value, self.path)
- cmd = eucadmin.command.Command(cmd_str, self.test)
+ cmd = eucadmin.command.Command(cmd_str)
dict.__setitem__(self, key, value)
def _read_config_data(self):
@@ -76,13 +76,13 @@ def _backup(self):
def comment(self, pattern):
self.backup()
cmd_str = self.CommentCmd % (pattern, self.path)
- cmd = eucadmin.command.Command(cmd_str, self.test)
+ cmd = eucadmin.command.Command(cmd_str)
if pattern in self:
del self[pattern]
def uncomment(self, pattern):
self.backup()
cmd_str = self.UncommentCmd % (pattern, self.path)
- cmd = eucadmin.command.Command(cmd_str, self.test)
+ cmd = eucadmin.command.Command(cmd_str)
self['pattern'] = ''
View
313 storage/http.c.moved
@@ -1,313 +0,0 @@
-// -*- mode: C; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil -*-
-// vim: set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
-
-/*
- Copyright (c) 2009 Eucalyptus Systems, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, only version 3 of the License.
-
- This file is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program. If not, see <http://www.gnu.org/licenses/>.
-
- Please contact Eucalyptus Systems, Inc., 130 Castilian
- Dr., Goleta, CA 93101 USA or visit <http://www.eucalyptus.com/licenses/>
- if you need additional information or have any questions.
-
- This file may incorporate work covered under the following copyright and
- permission notice:
-
- Software License Agreement (BSD License)
-
- Copyright (c) 2008, Regents of the University of California
-
-
- Redistribution and use of this software in source and binary forms, with
- or without modification, are permitted provided that the following
- conditions are met:
-
- Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. USERS OF
- THIS SOFTWARE ACKNOWLEDGE THE POSSIBLE PRESENCE OF OTHER OPEN SOURCE
- LICENSED MATERIAL, COPYRIGHTED MATERIAL OR PATENTED MATERIAL IN THIS
- SOFTWARE, AND IF ANY SUCH MATERIAL IS DISCOVERED THE PARTY DISCOVERING
- IT MAY INFORM DR. RICH WOLSKI AT THE UNIVERSITY OF CALIFORNIA, SANTA
- BARBARA WHO WILL THEN ASCERTAIN THE MOST APPROPRIATE REMEDY, WHICH IN
- THE REGENTS' DISCRETION MAY INCLUDE, WITHOUT LIMITATION, REPLACEMENT
- OF THE CODE SO IDENTIFIED, LICENSING OF THE CODE SO IDENTIFIED, OR
- WITHDRAWAL OF THE CODE CAPABILITY TO THE EXTENT NEEDED TO COMPLY WITH
- ANY SUCH LICENSES OR RIGHTS.
-*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <time.h>
-#include <unistd.h> // close, stat
-#include <assert.h>
-#include <string.h>
-#include <strings.h>
-#include <fcntl.h> // open
-#include <ctype.h> // tolower, isdigit
-#include <sys/types.h> // stat
-#include <sys/stat.h> // stat
-#include <curl/curl.h>
-#include <curl/easy.h>
-
-#ifndef _UNIT_TEST // http_ functions aren't part of the unit test
-#include "config.h"
-#include "eucalyptus.h"
-#include "misc.h"
-
-#define TOTAL_RETRIES 3 /* download is retried in case of connection problems */
-#define FIRST_TIMEOUT 4 /* in seconds, goes in powers of two afterwards */
-#define STRSIZE 245 /* for short strings: files, hosts, URLs */
-
-static size_t read_data (char *bufptr, size_t size, size_t nitems, void *userp);
-
-struct request {
- FILE * fp; /* input file pointer to be used by curl READERs */
- long long total_read; /* bytes written during the operation */
- long long total_calls; /* write calls made during the operation */
- time_t timestamp; // timestamp for periodically printing progress messages
- long long file_size; // file size in bytes, to print in progress messages
-};
-
-static int curl_initialized = 0;
-
-int http_put (const char * file_path, const char * url, const char * login, const char * password)
-{
- int code = ERROR;
-
- if (curl_initialized!=1) {
- curl_global_init(CURL_GLOBAL_SSL);
- curl_initialized = 1;
- }
-
- struct stat64 mystat;
- if (stat64 (file_path, &mystat)) {
- logprintfl (EUCAERROR, "http_put(): failed to stat %s\n", file_path);
- return code;
- }
- if (!S_ISREG(mystat.st_mode)) {
- logprintfl (EUCAERROR, "http_put(): %s is not a regular file\n", file_path);
- return code;
- }
-
- FILE * fp = fopen64 (file_path, "r");
- if (fp==NULL) {
- logprintfl (EUCAERROR, "http_put(): failed to open %s for reading\n", file_path);
- return code;
- }
-
- CURL * curl;
- CURLcode result;
- curl = curl_easy_init ();
- if (curl==NULL) {
- logprintfl (EUCAERROR, "http_put(): could not initialize libcurl\n");
- fclose (fp);
- return code;
- }
-
- logprintfl (EUCAINFO, "http_put(): uploading %s\n", file_path);
- logprintfl (EUCAINFO, " to %s\n", url);
-
- char error_msg [CURL_ERROR_SIZE];
- curl_easy_setopt (curl, CURLOPT_ERRORBUFFER, error_msg);
- curl_easy_setopt (curl, CURLOPT_URL, url);
- curl_easy_setopt (curl, CURLOPT_UPLOAD, 1L);
- curl_easy_setopt (curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t)mystat.st_size);
- curl_easy_setopt (curl, CURLOPT_SSL_VERIFYPEER, 0L); // TODO: make this optional?
- curl_easy_setopt (curl, CURLOPT_SSL_VERIFYHOST, 0L);
- curl_easy_setopt (curl, CURLOPT_LOW_SPEED_LIMIT, 360L); // must have at least a 360 baud modem
- curl_easy_setopt (curl, CURLOPT_LOW_SPEED_TIME, 10L); // abort if below speed limit for this many seconds
-
- if (login!=NULL && password!=NULL) {
- char userpwd [STRSIZE];
- snprintf (userpwd, STRSIZE, "%s:%s", login, password);
- curl_easy_setopt (curl, CURLOPT_USERPWD, userpwd);
- }
-
- struct request params;
- params.fp = fp;
- params.timestamp = time(NULL);
- params.file_size = (long long)mystat.st_size;
- curl_easy_setopt (curl, CURLOPT_READDATA, &params);
- curl_easy_setopt (curl, CURLOPT_READFUNCTION, read_data);
-
- int retries = TOTAL_RETRIES;
- int timeout = FIRST_TIMEOUT;
- do {
- params.total_read = 0L;
- params.total_calls = 0L;
- result = curl_easy_perform (curl); /* do it */
- logprintfl (EUCADEBUG, "http_put(): uploaded %ld bytes in %ld sends\n", params.total_read, params.total_calls);
-
- if (result) { // curl error (connection or transfer failed)
- logprintfl (EUCAERROR, "http_put(): %s (%d)\n", error_msg, result);
-
- } else {
- long httpcode;
- curl_easy_getinfo (curl, CURLINFO_RESPONSE_CODE, &httpcode);
- // TODO: pull out response message, too?
-
- switch (httpcode) {
- case 200L: // all good
- logprintfl (EUCAINFO, "http_put(): file updated sucessfully\n");
- code = OK;
- break;
- case 201L: // all good, created
- logprintfl (EUCAINFO, "http_put(): file created sucessfully\n");
- code = OK;
- break;
- case 408L: // timeout, retry
- logprintfl (EUCAWARN, "http_put(): server responded with HTTP code %ld (timeout)\n", httpcode);
- break;
- case 500L: // internal server error (could be a fluke, so we'll retry)
- logprintfl (EUCAWARN, "http_put(): server responded with HTTP code %ld (transient?)\n", httpcode);
- break;
- default: // some kind of error, will not retry
- logprintfl (EUCAERROR, "http_put(): server responded with HTTP code %ld\n", httpcode);
- retries = 0;
- }
- }
-
- if (code!=OK && retries > 0) {
- logprintfl (EUCAERROR, " upload retry %d of %d will commence in %d seconds\n", TOTAL_RETRIES-retries+1, TOTAL_RETRIES, timeout);
- sleep (timeout);
- fseek (fp, 0L, SEEK_SET);
- timeout <<= 1;
- }
-
- retries--;
- } while (code!=OK && retries>0);
- fclose (fp);
-
- curl_easy_cleanup (curl);
- return code;
-}
-
-/* libcurl read handler */
-static size_t read_data (char *buffer, size_t size, size_t nitems, void *params)
-{
- assert (params != NULL);
-
- FILE * fp = ((struct request *)params)->fp;
- int items_read = 0;
- do {
- items_read += fread (buffer, size, nitems-items_read, fp);
- } while (items_read!=nitems && !feof(fp));
-
- ((struct request *)params)->total_read += items_read * size;
- ((struct request *)params)->total_calls++;
-
- if (((struct request *)params)->total_calls%50==0) {
- time_t prev = ((struct request *)params)->timestamp;
- time_t now = time(NULL);
- if ((now-prev)>10) {
- ((struct request *)params)->timestamp = now;
- long long bytes_read = ((struct request *)params)->total_read;
- long long bytes_file = ((struct request *)params)->file_size;
- int percent = (int)((bytes_read*100)/bytes_file);
- logprintfl (EUCADEBUG, "http_put(): upload progress %ld/%ld bytes (%d%%)\n", bytes_read, bytes_file, percent);
- }
- }
-
- return items_read;
-}
-
-#endif
-
-// converts hex character to integer
-static char hch_to_int (char ch) {
- return isdigit (ch) ? (ch - '0') : (10 + tolower (ch) - 'a');
-}
-
-// converts integer to hex character
-static char int_to_hch (char i) {
- static char hex[] = "0123456789ABCDEF";
- return hex [i & 15];
-}
-
-// converts a string to url-encoded string (which must be freed)
-char * url_encode (const char * unencoded) {
- char * encoded = malloc (strlen (unencoded) * 3 + 1);
- if (encoded==NULL) return NULL;
-
- const char * pu = unencoded;
- char * pe = encoded;
- while (*pu) {
- if (isalnum (*pu)
- || *pu == '-'
- || *pu == '_'
- || *pu == '.'
- || *pu == '~')
- *pe++ = *pu;
- else if (*pu == ' ')
- *pe++ = '+';
- else {
- *pe++ = '%';
- *pe++ = int_to_hch (*pu >> 4);
- *pe++ = int_to_hch (*pu & 15);
- }
- pu++;
- }
- *pe = '\0';
-
- return encoded;
-}
-
-// converts a url-encoded string to regular (which must be freed)
-char * url_decode (const char * encoded) {
- char * unencoded = malloc (strlen (encoded) + 1);
- if (unencoded==NULL) return NULL;
-
- const char * pe = encoded;
- char * pu = unencoded;
- while (*pe) {
- if (*pe == '%') {
- if (pe[1] && pe[2]) {
- *pu++ = hch_to_int (pe[1]) << 4 | hch_to_int (pe[2]);
- pe += 2;
- }
- } else if (*pe == '+') {
- *pu++ = ' ';
- } else {
- *pu++ = *pe;
- }
- pe++;
- }
- *pu = '\0';
-
- return unencoded;
-}
-
-#ifdef _UNIT_TEST
-int main (int argc, char ** argv)
-{
-#define _T(_S) { char * e = url_encode (_S); char * u = url_decode (e); printf ("orig: %s\nenco: %s\ndeco: %s\n\n", _S, e, u); free (e); free (u); }
- _T("hello world");
- _T("~`!1@2#3$4%5^6&7*8(9)0_-+={[}]|\\:;\"'<,>.?/");
- _T("[datastore1 (1)] windows 2003 enterprise/windows 2003 enterprise.vmx");
-}
-#endif
View
68 storage/http.h.moved
@@ -1,68 +0,0 @@
-// -*- mode: C; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil -*-
-// vim: set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
-
-/*
- Copyright (c) 2009 Eucalyptus Systems, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, only version 3 of the License.
-
- This file is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program. If not, see <http://www.gnu.org/licenses/>.
-
- Please contact Eucalyptus Systems, Inc., 130 Castilian
- Dr., Goleta, CA 93101 USA or visit <http://www.eucalyptus.com/licenses/>
- if you need additional information or have any questions.
-
- This file may incorporate work covered under the following copyright and
- permission notice:
-
- Software License Agreement (BSD License)
-
- Copyright (c) 2008, Regents of the University of California
-
-
- Redistribution and use of this software in source and binary forms, with
- or without modification, are permitted provided that the following
- conditions are met:
-
- Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. USERS OF
- THIS SOFTWARE ACKNOWLEDGE THE POSSIBLE PRESENCE OF OTHER OPEN SOURCE
- LICENSED MATERIAL, COPYRIGHTED MATERIAL OR PATENTED MATERIAL IN THIS
- SOFTWARE, AND IF ANY SUCH MATERIAL IS DISCOVERED THE PARTY DISCOVERING
- IT MAY INFORM DR. RICH WOLSKI AT THE UNIVERSITY OF CALIFORNIA, SANTA
- BARBARA WHO WILL THEN ASCERTAIN THE MOST APPROPRIATE REMEDY, WHICH IN
- THE REGENTS' DISCRETION MAY INCLUDE, WITHOUT LIMITATION, REPLACEMENT
- OF THE CODE SO IDENTIFIED, LICENSING OF THE CODE SO IDENTIFIED, OR
- WITHDRAWAL OF THE CODE CAPABILITY TO THE EXTENT NEEDED TO COMPLY WITH
- ANY SUCH LICENSES OR RIGHTS.
-*/
-#ifndef HTTP_H
-#define HTTP_H
-int http_put (const char * file_name, const char * url, const char * login, const char * password);
-char * url_encode (const char * unencoded);
-char * url_decode (const char * encoded);
-#endif /* HTTP_H */
View
301 storage/storage-windows.c.moved
@@ -1,301 +0,0 @@
-// -*- mode: C; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil -*-
-// vim: set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
-
-#define _FILE_OFFSET_BITS 64 // so large-file support works on 32-bit systems
-#include <stdio.h>
-#include <stdlib.h>
-#define __USE_GNU /* strnlen */
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <dirent.h> /* open|read|close dir */
-#include <time.h> /* time() */
-#include <stdint.h>
-#include <arpa/inet.h>
-
-#include <openssl/sha.h>
-#include <openssl/rsa.h>
-#include <openssl/pem.h>
-#include <openssl/bio.h>
-#include <openssl/evp.h>
-#include <openssl/err.h>
-
-#include <storage-windows.h>
-#include <euca_auth.h>
-#include <misc.h>
-
-int decryptWindowsPassword(char *encpass, int encsize, char *pkfile, char **out) {
- FILE *PKFP;
- RSA *pr=NULL;
- char *dec64;
- int rc;
-
- if (!encpass || encsize <= 0 || !*pkfile || !out) {
- return(1);
- }
-
- PKFP = fopen(pkfile, "r");
- if (!PKFP) {
- return(1);
- }
- if (PEM_read_RSAPrivateKey(PKFP, &pr, NULL, NULL) == NULL) {
- return(1);
- }
-
- dec64 = base64_dec((unsigned char *)encpass, strlen(encpass));
- if (!dec64) {
- return(1);
- }
-
- *out = malloc(512);
- if(!*out) {
- if (dec64) free(dec64);
- return(1);
- }
- bzero(*out, 512);
- rc = RSA_private_decrypt(encsize, (unsigned char *)dec64, (unsigned char *)*out, pr, RSA_PKCS1_PADDING);
- if (dec64) free(dec64);
- if (rc) {
- return(1);
- }
- return(0);
-}
-
-
-int encryptWindowsPassword(char *pass, char *key, char **out, int *outsize) {
- char *sshkey_dec, *modbuf, *exponentbuf;
- char *ptr, *tmp, hexstr[4], *enc64;
- char *dec64, encpassword[512];
-
- uint32_t len, exponent;
- int size, ilen, i, encsize=0, rc;
- RSA *r=NULL;
-
- if (!pass || !key || !out || !outsize) {
- return(1);
- }
-
- size = strlen(key);
- sshkey_dec = base64_dec((unsigned char *)key, size);
- if (!sshkey_dec) {
- return(1);
- }
-
- ptr = sshkey_dec;
- memcpy(&len, ptr, 4);
- len = htonl(len);
- ptr+=4+len;
-
- memcpy(&len, ptr, 4);
- len = htonl(len);
- ptr+=4;
-
- // read public exponent
- exponentbuf = malloc(32768);
- if (!exponentbuf) {
- if (sshkey_dec) free(sshkey_dec);
- return(1);
- }
- exponent = 0;
- memcpy(&exponent, ptr, len);
- exponent = htonl(exponent);
- exponent = htonl(exponent);
- snprintf(exponentbuf, 128, "%08X", exponent);
- ptr+=len;
-
- memcpy(&len, ptr, 4);
- len = htonl(len);
- ptr+=4;
-
- // read modulus material
- modbuf = malloc(32768);
- if (!modbuf) {
- if (sshkey_dec) free(sshkey_dec);
- if (exponentbuf) free(exponentbuf);
- return(1);
- }
- bzero(modbuf, 32768);
- ilen = (int)len;
- for (i=0; i<ilen; i++) {
- tmp = strndup(ptr, 1);
- if (tmp) {
- len = *tmp;
- bzero(hexstr, sizeof(char) * 4);
- snprintf(hexstr, 3, "%02X", (len<<24)>>24);
- strcat(modbuf, hexstr);
- ptr+=1;
- free(tmp);
- }
- }
- //printf("MOD: |%s|\n", modbuf);
- //printf("EXPONENT: |%s|\n", exponentbuf);
-
- r = RSA_new();
- if (!r) {
- if (sshkey_dec) free(sshkey_dec);
- if (exponentbuf) free(exponentbuf);
- if (modbuf) free(modbuf);
- return(1);
- }
- if (!BN_hex2bn(&(r->e), exponentbuf) || !BN_hex2bn(&(r->n), modbuf)) {
- if (sshkey_dec) free(sshkey_dec);
- if (exponentbuf) free(exponentbuf);
- if (modbuf) free(modbuf);
- return(1);
- }
-
- bzero(encpassword, 512);
- encsize = RSA_public_encrypt(strlen(pass), (unsigned char *)pass, (unsigned char *)encpassword, r, RSA_PKCS1_PADDING);
- if (encsize <= 0) {
- if (sshkey_dec) free(sshkey_dec);
- if (exponentbuf) free(exponentbuf);
- if (modbuf) free(modbuf);
- return(1);
- }
-
- *out = base64_enc((unsigned char *)encpassword, encsize);
- *outsize = encsize;
- if (!*out || *outsize <= 0) {
- if (sshkey_dec) free(sshkey_dec);
- if (exponentbuf) free(exponentbuf);
- if (modbuf) free(modbuf);
- return(1);
- }
- if (sshkey_dec) free(sshkey_dec);
- if (exponentbuf) free(exponentbuf);
- if (modbuf) free(modbuf);
- return(0);
-}
-
-
-int makeWindowsFloppy(char *euca_home, char *rundir_path, char *keyName, char *instName) {
- int fd, rc, rbytes, count, encsize, i;
- char *buf, *ptr, *tmp, *newpass, dest_path[1024], source_path[1024], fname[1024], password[16];
- char *encpassword;
- char *newInstName;
- FILE *FH;
-
- if (!keyName || !strlen(keyName) || !strlen(instName)) {
- return(0);
- }
-
- if (!euca_home || !rundir_path || !strlen(euca_home) || !strlen(rundir_path)) {
- return(1);
- }
-
- bzero(password, sizeof(char)*16);
- for (i=0; i<8; i++) {
- char c[4];
- c[0] = '0';
- while(c[0] == '0' || c[0] == 'O') snprintf(c, 2, "%c", RANDALPHANUM);
- strcat(password, c);
- }
- snprintf(source_path, 1024, "%s/usr/share/eucalyptus/floppy", euca_home);
- snprintf(dest_path, 1024, "%s/floppy", rundir_path);
-
- buf = malloc(1024 * 2048);
- if (!buf) {
- return(1);
- }
-
- fd = open(source_path, O_RDONLY);
- if (fd < 0) {
- if (buf) free(buf);
- return(1);
- }
-
- rbytes = read(fd, buf, 1024 * 2048);
- close(fd);
- if (rbytes < 0) {
- if (buf) free(buf);
- return(1);
- }
-
- ptr = buf;
- count=0;
- tmp = malloc(sizeof(char) * strlen("MAGICEUCALYPTUSPASSWORDPLACEHOLDER")+1);
- newpass = malloc(sizeof(char) * strlen("MAGICEUCALYPTUSPASSWORDPLACEHOLDER")+1);
- newInstName = malloc(sizeof(char) * strlen("MAGICEUCALYPTUSHOSTNAMEPLACEHOLDER")+1);
-
- if (!tmp || !newpass || !newInstName) {
- if (tmp) free(tmp);
- if (newpass) free(newpass);
- if (newInstName) free(newInstName);
- if (buf) free(buf);
- return(1);
- }
- bzero(tmp, strlen("MAGICEUCALYPTUSPASSWORDPLACEHOLDER")+1);
- bzero(newpass, strlen("MAGICEUCALYPTUSPASSWORDPLACEHOLDER")+1);
- bzero(newInstName, strlen("MAGICEUCALYPTUSHOSTNAMEPLACEHOLDER")+1);
-
- snprintf(newpass, strlen(password)+1, "%s", password);
- snprintf(newInstName, strlen(instName)+1, "%s", instName);
-
- while(count < rbytes) {
- memcpy(tmp, ptr, strlen("MAGICEUCALYPTUSPASSWORDPLACEHOLDER"));
- if (!strcmp(tmp, "MAGICEUCALYPTUSPASSWORDPLACEHOLDER")) {
- memcpy(ptr, newpass, strlen("MAGICEUCALYPTUSPASSWORDPLACEHOLDER"));
- }
-
- if (!strcmp(tmp, "MAGICEUCALYPTUSHOSTNAMEPLACEHOLDER")) {
- memcpy(ptr, newInstName, strlen("MAGICEUCALYPTUSHOSTNAMEPLACEHOLDER"));
- }
-
-
- ptr++;
- count++;
- }
-
- fd = open(dest_path, O_CREAT | O_TRUNC | O_RDWR, 0700);
- if (fd < 0) {
- if (buf) free(buf);
- if (tmp) free(tmp);
- if (newpass) free(newpass);
- if (newInstName) free(newInstName);
- return(1);
- }
- rc = write(fd, buf, rbytes);
- if (rc != rbytes) {
- if (buf) free(buf);
- if (tmp) free(tmp);
- if (newpass) free(newpass);
- if (newInstName) free(newInstName);
- return(1);
- }
- close(fd);
- if (buf) free(buf);
-
- // encrypt password and write to console log for later retrieval
- char tmpstr[512], enckey[2048];
- sscanf(keyName, "%s %s %s", tmp, enckey, tmp);
- rc = encryptWindowsPassword(password, enckey, &encpassword, &encsize);
- if (rc) {
- if (tmp) free(tmp);
- if (newpass) free(newpass);
- if (newInstName) free(newInstName);
- return(1);
- }
-
- snprintf(dest_path, 1024, "%s/console.append.log", rundir_path);
- FH = fopen(dest_path, "w");
- if (FH) {
- fprintf(FH, "<Password>\r\n%s\r\n</Password>\r\n", encpassword);
- fclose(FH);
- } else {
- if (encpassword) free(encpassword);
- if (tmp) free(tmp);
- if (newpass) free(newpass);
- if (newInstName) free(newInstName);
- return(1);
- }
- if (encpassword) free(encpassword);
- if (tmp) free(tmp);
- if (newpass) free(newpass);
- if (newInstName) free(newInstName);
- return(0);
-}
View
11 storage/storage-windows.h.moved
@@ -1,11 +0,0 @@
-// -*- mode: C; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil -*-
-// vim: set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
-
-#ifndef INCLUDE_STORAGE_WINDOWS_H
-#define INCLUDE_STORAGE_WINDOWS_H
-
-int makeWindowsFloppy(char *euca_home, char *rundir_path, char *keyName, char *instName);
-int encryptWindowsPassword(char *pass, char *key, char **out, int *outsize);
-int decryptWindowsPassword(char *encpass, int encsize, char *pkfile, char **out);
-
-#endif
View
255 tools/connect_iscsitarget_sc.pl.moved
@@ -1,255 +0,0 @@
-#!/usr/bin/perl
-
-use Crypt::OpenSSL::Random ;
-use Crypt::OpenSSL::RSA ;
-use MIME::Base64;
-
-
-delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
-$ENV{'PATH'}='/bin:/usr/bin:/sbin:/usr/sbin/';
-$P12_PATH="";
-
-$DELIMITER = ",";
-$ISCSIADM = untaint(`which iscsiadm`);
-$OPENSSL = untaint(`which openssl`);
-$ISCSI_USER = "eucalyptus";
-
-# check binaries
-if (!-x $ISCSIADM || !-x $OPENSSL) {
- print STDERR "Unable to find required dependencies\n";
- do_exit(1);
-}
-
-# check input params
-$dev_string = untaint(shift @ARGV);
-
-($euca_home, $ip, $store, $encrypted_password, $lun, $auth_mode) = parse_devstring($dev_string);
-
-if(length($euca_home) <= 0) {
- print STDERR "EUCALYPTUS path is not defined.\n";
- do_exit(1);
-}
-
-$P12_PATH = $euca_home."/var/lib/eucalyptus/keys/euca.p12";
-
-$sc_pk = get_storage_pk();
-
-if((length($ip) <= 0) || (length($store) <= 0) || length($encrypted_password) <= 0) {
- print STDERR "Invalid input. Need to specify IP,STORE,ENCRYPTED_PASS\n";
- do_exit(1);
-}
-
-
-if ((length($lun) > 0) && ($lun > -1)) {
- # check if a session corresponding to the store exists
- if (get_session($ARGV[0]) == 1) {
- # rescan session
- rescan_target();
- } else {
- # else login to session
- if(length($auth_mode) > 0) {
- $password = "not_required";
- } else {
- $password = decrypt_password($encrypted_password, $sc_pk);
- }
- if(length($password) <= 0) {
- print STDERR "Unable to decrypt target password. Aborting.\n";
- }
- login_target($ip, $store, $password, $auth_mode);
- }
- # get dev from lun
- sleep 1;
- print get_device_name_from_lun($store, $lun);
-} else {
- $password = decrypt_password($encrypted_password, $sc_pk);
-
- if(length($password) <= 0) {
- print STDERR "Unable to decrypt target password. Aborting.\n";
- }
- login_target($ip, $store, $password);
- #wait for device to be ready
- sleep 1;
- print get_device_name($store);
-}
-
-sub parse_devstring {
- my ($dev_string) = @_;
- return split($DELIMITER, $dev_string);
-}
-
-sub get_storage_pk {
- if(!open GET_KEY, "openssl pkcs12 -in $P12_PATH -name eucalyptus -name 'eucalyptus' -password pass:eucalyptus -passin pass:eucalyptus -passout pass:eucalyptus -nodes | grep -A30 'friendlyName: storage' | grep -A26 'BEGIN RSA' |") {
- print "Could not get storage key";
- do_exit(1)
- }
-
- my $pk = "";
-
- while(<GET_KEY>) {
- $pk = $pk.$_;
- };
-
- return $pk;
-}
-
-sub login_target {
- my ($ip, $store, $passwd) = @_;
- if(!open DISCOVERY, "iscsiadm -m discovery -t sendtargets -p $ip |") {
- print "Could not discover targets";
- do_exit(1)
- }
-
- while(<DISCOVERY>) {};
-
- if($password ne "not_required") {
- if(!open USERNAME, "iscsiadm -m node -T $store --op=update --name node.session.auth.username --value=$ISCSI_USER |") {
- print "Could not update target username";
- do_exit(1)
- }
-
- while(<USERNAME>) {};
-
- if(!open PASSWD, "iscsiadm -m node -T $store --op=update --name node.session.auth.password --value=$passwd |") {
- print "Could not update target password";
- do_exit(1)
- }
-
- while(<PASSWD>) {};
-
- }
-
- if(!open LOGIN, "iscsiadm -m node -T $store -l |") {
- print "Could not login to target";
- do_exit(1)
- }
-
- my $login = "";
- while(<LOGIN>) {$login = $login.$_;};
- if(length($login) <= 0) {
- print STDERR "Unable to login to target. Aborting.\n";
- do_exit(1);
- }
-}
-
-sub decrypt_password {
- my ($encrypted_passwd, $private_key) = @_;
-
- $rsa_priv = Crypt::OpenSSL::RSA->new_private_key($private_key);
-
- $msg = decode_base64($encrypted_passwd);
- $rsa_priv->use_pkcs1_padding();
- $rsa_priv->use_sha1_hash() ;
-
- my $passwd = $rsa_priv->decrypt($msg);
-
- return $passwd;
-}
-
-sub get_session {
- my ($store) = @_;
- $num_retries = 5;
-
- for ($i = 0; $i < $num_retries; ++$i) {
- if(!open GETSESSION, "iscsiadm -m session |") {
- print STDERR "Could not get iscsi session information";
- do_exit(1)
- }
-
- while (<GETSESSION>) {
- if ($_ =~ /.*$store\n/) {
- close GETSESSION;
- return 1;
- }
- }
- close GETSESSION;
- }
- return 0;
-}
-
-
-sub get_device_name {
- my ($store) = @_;
-
- if(!open GETSESSION, "iscsiadm -m session -P 3 |") {
- print "Could not get iscsi session information";
- do_exit(1)
- }
-
- $found_target = 0;
- while (<GETSESSION>) {
- if($_ =~ /Target: (.*)\n/) {
- $found_target = 1 if $1 eq $store;
- } elsif($_ =~ /.*Attached scsi disk ([a-zA-Z0-9]+).*\n/) {
- if($found_target == 1) {
- return "/dev/".$1;
- }
- }
- }
- close GETSESSION;
-}
-
-sub get_device_name_from_lun {
- my ($store, $lun) = @_;
- $num_retries = 5;
-
- for ($i = 0; $i < $num_retries; ++$i) {
- if(!open GETSESSION, "iscsiadm -m session -P 3 |") {
- print STDERR "Could not get iscsi session information";
- do_exit(1)
- }
-
- $found_target = 0;
- $found_lun = 0;
- $attach_seen = 1;
- while (<GETSESSION>) {
- if ($_ =~ /Target: (.*)\n/) {
- last if $attach_seen == 0;
- $found_target = 1 if $1 eq $store;
- $attach_seen = 0;
- $found_lun = 0;
- } elsif ($_ =~ /.*Attached scsi disk ([a-zA-Z0-9]+).*\n/) {
- if ($found_target == 1 && $found_lun == 1) {
- return "/dev/", $1;
- }
- $attach_seen = 1;
- } elsif ($_ =~ /.*Lun: (.*)\n/) {
- $found_lun = 1 if $1 eq $lun;
- }
- }
- close GETSESSION;
- }
-}
-
-sub rescan_target {
-
- if(!open GETSESSION, "iscsiadm -m session -R |") {
- print STDERR "Could not get iscsi session information";
- do_exit(1)
- }
- close GETSESSION;
-}
-
-sub do_exit() {
- $e = shift;
-
- if ($mounted && ($tmpfile ne "")) {
- system("$mounter umount $tmpfile");
- }
- if ($attached && ($loopdev ne "")) {
- system("$LOSETUP -d $loopdev");
- }
- if ($tmpfile ne "") {
- system("$RMDIR $tmpfile");
- }
- exit($e);
-}
-
-sub untaint() {
- $str = shift;
- if ($str =~ /^([ &:#-\@\w.]+)$/) {
- $str = $1; #data is now untainted
- } else {
- $str = "";
- }
- return($str);
-}
View
216 tools/disconnect_iscsitarget_sc.pl.moved
@@ -1,216 +0,0 @@
-#!/usr/bin/perl
-
-use Crypt::OpenSSL::Random;
-use Crypt::OpenSSL::RSA;
-use MIME::Base64;
-
-delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
-$ENV{'PATH'}='/bin:/usr/bin:/sbin:/usr/sbin/';
-
-$P12_PATH="";
-$ISCSI_USER="eucalyptus";
-
-$DELIMITER = ",";
-$ISCSIADM = untaint(`which iscsiadm`);
-$OPENSSL = untaint(`which openssl`);
-
-# check binaries
-
-if (!-x $ISCSIADM || !-x $OPENSSL) {
- print STDERR "Unable to find required dependencies\n";
- do_exit(1);
-}
-
-# check input params
-$dev_string = untaint(shift @ARGV);
-
-($euca_home, $ip, $store, $encrypted_password, $lun, $auth_mode) = parse_devstring($dev_string);
-
-if(length($euca_home) <= 0) {
- print STDERR "EUCALYPTUS path is not defined.\n";
- do_exit(1);
-}
-
-$P12_PATH = $euca_home."/var/lib/eucalyptus/keys/euca.p12";
-
-$sc_pk = get_storage_pk();
-
-if((length($ip) <= 0) || (length($store) <= 0) || length($encrypted_password) <= 0) {
- print STDERR "Invalid input. Need to specify IP,STORE,ENCRYPTED_PASS\n";
- do_exit(1);
-}
-
-#$password = decrypt_password($encrypted_password, $sc_pk);
-
-$passwd = "not_required";
-#if(length($password) <= 0) {
- # print STDERR "Unable to decrypt target password. Aborting.\n";
-#}
-
-if ((length($lun) > 0) && ($lun > -1)) {
- delete_lun($store, $lun);
- rescan_target();
- if(only_device($store, $lun)) {
- logout_target($ip, $store, $passwd);
- }
-} else {
- logout_target($ip, $store, $passwd);
-}
-
-
-sub get_storage_pk {
- if(!open GET_KEY, "openssl pkcs12 -in $P12_PATH -name eucalyptus -name 'eucalyptus' -password pass:eucalyptus -passin pass:eucalyptus -passout pass:eucalyptus -nodes | grep -A30 'friendlyName: storage' | grep -A26 'BEGIN RSA' |") {
- print "Could not get storage key";
- do_exit(1)
- }
-
- my $pk = "";
-
- while(<GET_KEY>) {
- $pk = $pk.$_;
- };
-
- return $pk;
-}
-
-
-sub parse_devstring {
- my ($dev_string) = @_;
- return split($DELIMITER, $dev_string);
-}
-
-sub delete_lun {
- my ($store, $lun) = @_;
- $num_retries = 1;
-
- for ($i = 0; $i < $num_retries; ++$i) {
- if(!open GETSESSION, "iscsiadm -m session -P 3 |") {
- print STDERR "Could not get iscsi session information";
- do_exit(1)
- }
-
- $found_target = 0;
- $sid = -1;
- $host_number = -1;
- while (<GETSESSION>) {
- if ($_ =~ /Target: (.*)\n/) {
- $found_target = 1 if $1 eq $store;
- } elsif ($_ =~ /.*SID: (.*)\n/) {
- if ($found_target == 1) {
- $sid = $1;
- }
- } elsif ($_ =~ /.*Host Number:\s(.*)\sState.*\n/) {
- if ($found_target == 1) {
- $host_number = $1;
- last;
- }
- }
- }
- close GETSESSION;
- }
- return if $sid < 0 && $host_number < 0;
- #this path is kernel specific. FIXME.
- $delete_path = "/sys/class/iscsi_session/session$sid/device/target$host_number:0:0/$host_number:0:0:$lun/delete";
- if (!open DELETELUN, ">$delete_path") {
- print STDERR "Unable to write to $delete_path\n";
- do_exit(1);
- }
- print DELETELUN "1";
- close DELETELUN;
-}
-
-sub only_device {
- my ($store, $lun) = @_;
- $num_retries = 5;
- for ($i = 0; $i < $num_retries; ++$i) {
- $only = 1;
- if(!open GETSESSION, "iscsiadm -m session -P 3 |") {
- print STDERR "Could not get iscsi session information";
- do_exit(1)
- }
-
- $found_target = 0;
- while (<GETSESSION>) {
- if ($_ =~ /Target: (.*)\n/) {
- last if $found_target == 1;
- if ($1 eq $store) {
- $found_target = 1;
- $only = 1;
- }
- } elsif ($_ =~ /.*Attached scsi disk ([a-zA-Z0-9]+).*\n/) {
- if ($found_target == 1) {
- $only = 0;
- last;
- }
- }
- }
- close GETSESSION;
- }
- return $only;
-}
-
-sub rescan_target {
- if(!open GETSESSION, "iscsiadm -m session -R |") {
- print STDERR "Could not get iscsi session information";
- do_exit(1)
- }
- close GETSESSION;
- print "Done rescanning.";
-}
-
-sub logout_target {
- my ($ip, $store, $passwd) = @_;
-
-
- if(!open DISCONNECT, "$ISCSIADM -m node -T $store -p $ip -u |") {
- print "Could not logout from target";
- do_exit(1);
- }
-
- my $logout = "";
- while(<DISCONNECT>) {$logout = $logout.$_;};
- if(length($logout) <= 0) {
- print STDERR "Unable to log out of target. Aborting.\n";
- do_exit(1);
- }
- print $logout;
-}
-
-sub do_exit() {
- $e = shift;
-
- if ($mounted && ($tmpfile ne "")) {
- system("$mounter umount $tmpfile");
- }
- if ($attached && ($loopdev ne "")) {
- system("$LOSETUP -d $loopdev");
- }
- if ($tmpfile ne "") {
- system("$RMDIR $tmpfile");
- }
- exit($e);
-}
-
-sub untaint() {
- $str = shift;
- if ($str =~ /^([ &:#-\@\w.]+)$/) {
- $str = $1; #data is now untainted
- } else {
- $str = "";
- }
- return($str);
-}
-
-sub decrypt_password {
- my ($encrypted_passwd, $private_key) = @_;
-
- $rsa_priv = Crypt::OpenSSL::RSA->new_private_key($private_key);
-
- $msg = decode_base64($encrypted_passwd);
- $rsa_priv->use_pkcs1_padding();
- $rsa_priv->use_sha1_hash() ;
-
- my $passwd = $rsa_priv->decrypt($msg);
-
- return $passwd;
-}
View
143 tools/dynserv.pl.moved
@@ -1,143 +0,0 @@
-#!/usr/bin/perl
-
-use File::Path;
-
-my $eucalyptus = $ENV{'EUCALYPTUS'};
-my $dynpath = "$eucalyptus/var/lib/eucalyptus/dynserv";
-my $rc;
-my $dynpath = shift @ARGV;
-my @allowhosts = @ARGV;
-
-$rc = setup_dynpath($dynpath);
-if ($rc) {
- print "ERROR: could not create directory structure\n";
- exit (1);
-}
-
-$rc = open(OFH, ">$dynpath/dynserv-httpd.conf");
-if ($rc <= 0) {
- print "ERROR: could not create config file '$dynpath/dynserv-httpd.conf'\n";
- exit (1);
-}
-
-$authz = find_authz();
-$apache = find_apache2();
-if ($authz eq "none" || $apache eq "none") {
- print "ERROR: cannot find authz module ($authz) or apache2 ($apache)\n";
- exit (1);
-}
-
-$rc = prepare_configfile($eucalyptus, $dynpath, "eucalyptus", "eucalyptus", $authz, $apache, @allowhosts);
-if ($rc) {
- print "ERROR: could not set up configfile\n";
- exit(1);
-}
-
-$rc = restart_apache($dynpath, $apache);
-if ($rc) {
- print "ERROR: could not restart apache2\n";
- exit(1);
-}
-
-exit(0);
-
-sub restart_apache() {
- my $dynpath = shift @_;
- my $apache = shift @_;
-
- my $cmd = "$apache -f $dynpath/dynserv-httpd.conf -k graceful";
- my $rc = system("$cmd");
- if ($rc) {
- print "ERROR: could not run cmd '$cmd'\n";
- }
- return($rc);
-}
-
-sub prepare_configfile() {
- my $eucalyptus = shift @_;
- my $dynpath = shift @_;
- my $user = shift @_;
- my $group = shift @_;
- my $authz = shift @_;
- my $apache = shift @_;
- my @allowhosts = @_;
-
- if (!-d "$eucalyptus/var/run/eucalyptus" || !-d "$eucalyptus/var/log/eucalyptus") {
- print "ERROR: eucalyptus root '$eucalyptus' not found\n";
- return(1);
- }
- if (!-d "$eucalyptus" || !-d "$dynpath" || !-e "$authz" || !-x "$apache") {
- print "ERROR: eucalyptus=$eucalyptus dynpath=$dynpath user=$user group=$group authz=$authz apache=$apache\n";
- return(1);
- }
-
- $allows = "127.0.0.0/8";
- foreach $host (@allowhosts) {
- $allows = $allows . " $host";
- }
-
- print OFH <<EOF;
-ServerTokens OS
-ServerRoot "$dynpath"
-ServerName 127.0.0.1
-Listen 8776
-KeepAliveTimeout 30
-PidFile $eucalyptus/var/run/eucalyptus/httpd-dynserv.pid
-User $user
-group $group
-ErrorLog $eucalyptus/var/log/eucalyptus/httpd-dynserv-err.log
-LogLevel warn
-LoadModule authz_host_module $authz
-DocumentRoot "$dynpath/data/"
-<Directory "$dynpath/data/">
- Order deny,allow
-# Allow from 127.0.0.1
-# Allow from none
- Allow from $allows
- Deny from all
-</Directory>
-EOF
-close(OFH);
-return(0);
-}
-
-sub find_authz() {
- my @known_locations = ('/usr/lib64/httpd/modules/mod_authz_host.so',
- '/usr/lib/httpd/modules/mod_authz_host.so',
- '/usr/lib64/apache2/mod_authz_host.so',
- '/usr/lib/apache2/mod_authz_host.so',
- '/usr/lib/apache2/modules/mod_authz_host.so');
-
- $foundfile = "none";
- foreach $file (@known_locations) {
- if ( -f "$file" ) {
- $foundfile = $file;
- }
- }
- return($foundfile);
-}
-
-sub find_apache2() {
- my @known_locations = ('/usr/sbin/apache2',
- '/usr/sbin/httpd2',
- '/usr/sbin/httpd');
- $foundfile = "none";
- foreach $file (@known_locations) {
- if ( -x "$file" ) {
- $foundfile = $file;
- }
- }
- return($foundfile);
-}
-
-sub setup_dynpath() {
- my $root=shift @_;
-
- mkpath("$root/data/", {error => \my $err});
- if (@$err) {
- print "ERROR: could not create directory '$root/data'\n";
- return(1);
- }
-
- return(0);
-}
View
696 tools/eucanetd.moved
@@ -1,696 +0,0 @@
-#!/usr/bin/perl
-
-use Getopt::Std;
-use POSIX qw(setsid);
-use File::Compare;
-
-# globals
-my %localnets;
-my $localpubdev;
-my %secrules;
-my %secgroups;
-my %eucaconf;
-my $eucalyptus = "/";
-my $polltime = 1;
-my $iptpath = "/";
-my $iptmode = "iptables";
-my $dodhcpd = 0;
-my $vnetmode = "";
-my $cloudip = "169.254.169.254";
-
-if ($ENV{'EUCALYPTUS'}) {
- $eucalyptus = $ENV{'EUCALYPTUS'};
-}
-
-$rc = parse_eucalyptus_conf("$eucalyptus/etc/eucalyptus/eucalyptus.conf");
-if ($rc) {
- print "ERROR: eucanetd: cannot parse config file\n";
- exit(1);
-}
-
-getopts('cdp:l:m:', \%opts);
-my $logfile = $opts{'l'} || "$eucalyptus/var/log/eucalyptus/eucanetd.log";
-my $pidfile = $opts{'p'} || "$eucalyptus/var/run/eucalyptus/eucanetd.pid";
-my $debug = $opts{'d'} || 0;
-$iptmode = $opts{'m'} || $iptmode;
-$dodhcpd = $opts{'c'} || $dodhcpd;
-
-$rc = check_environment();
-if ($rc) {
- print "ERROR: eucanetd: cannot start eucanetd\n";
- exit(1);
-}
-
-if (!$debug) {
- chdir ('/') or die "Can't chdir to /: $!";
- umask (0);
- open STDIN, '/dev/null' or die "Can't read /dev/null: $!";
- open STDOUT, '>/dev/null' or die "Can't write to /dev/null: $!";
- open STDERR, '>/dev/null' or die "Can't write to /dev/null: $!";
- defined(my $pid = fork) or die "Can't fork: $!";
- exit if $pid;
- setsid() or die "Can't start a new session: $!";
-}
-
-if (open(PFH, ">$pidfile")) {
- print PFH "$$\n";
- close(PFH);
-}
-
-# main loop
-open(LFH, ">$logfile");
-while(1) {
- close(LFH);
- sleep($polltime);
- open(LFH, ">$logfile");
- print LFH "INIT: iptmode=$iptmode iptpath=$iptpath dodhcpd=$dodhcpd polltime=$polltime cloudip=$cloudip\n";
-
-# read local information
- %localnets = ();
- $rc = read_local_net();
- if ($rc) {
- print LFH "ERROR: eucanetd: could not read local net information\n";
- next;
- }
- print_local_net();
-
-# write global network information
- $rc = write_global_net();
- if ($rc) {
- print LFH "ERROR: eucanetd: could not access/write global net information\n";
- }
-
-# read global network information
- %secgroups = ();
- %secrules = ();
- $rc = read_global_net();
- if ($rc) {
- print LFH "ERROR: eucanetd: could not read global net information\n";
- next;
- }
- print_global_net();
- print LFH "-----------------------------\n\n";
-
- $file = write_iptrules();
- if ( ! -f "$file" ) {
- print LFH "ERROR: eucanetd: could not write iptables rules\n";
- next;
- }
-
- $restorefile = read_iptrules();
- if ( ! -f "$restorefile" ) {
- print LFH "ERROR: eucanetd: could not save previous iptables rules ('$cmd')\n";
- next;
- }
-
- $rc = deploy_iptrules($file);
- system("cat $file > /tmp/euca-iptables-rules");
- unlink($file);
- if ($rc) {
- print LFH "ERROR: eucanetd: could not install new iptables rules ('$cmd')\n";
- print LFH "INFO: restoring old iptables rules\n";
-
- $rc = deploy_iptrules($restorefile);
- unlink($restorefile);
- if ($rc) {
- print LFH "ERROR: eucanetd: could not restore previous iptables rules, flushing tables\n";
- system("$iptpath/sbin/iptables -t filter -F >/dev/null 2>&1");
- }
- print LFH "INFO: old iptables rules successfully restored\n";
- next;
- }
- unlink($restorefile);
-
- $efile = write_ebtrules();
- $rc = deploy_ebtrules($efile);
- unlink($efile);
- if ($rc) {
- print LFH "ERROR: eucanetd: could not deploy ebtrules\n";
- }
-
- if ($dodhcpd) {
- $dfile = write_dhcpconf();
- if ( ! -f "$dfile" ) {
- print LFH "ERROR: could not write DHCP config file\n";
- } else {
- $rc = deploy_dhcpd($dfile);
- if ($rc) {
- print LFH "ERROR: could not deploy DHCP daemon\n";
- }
- }
- }
-
-}
-
-sub write_dhcpconf() {
-
- my $retfile = "$eucalyptus/var/run/eucalyptus/net/euca-dhcp.conf.stage";
-
- open(DOFH, ">$retfile");
-
- print DOFH "# automatically generated config file for DHCP server\ndefault-lease-time 1200;\nmax-lease-time 1200;\nddns-update-style none;\n\nshared-network euca {\nsubnet $eucaconf{VNET_SUBNET} netmask $eucaconf{VNET_NETMASK} {\n option subnet-mask $eucaconf{VNET_NETMASK};\n option broadcast-address $eucaconf{VNET_BROADCAST};\n option domain-name-servers $eucaconf{VNET_DNS};\n option routers $eucaconf{VNET_ROUTER};\n}\n";
-
- my ($a, $b, $c, $d) = split('\.', $eucaconf{VNET_NETMASK});
- my $mask = sprintf("0x%02x%02x%02x%02x", $a, $b, $c, $d);
- my $hexmask = hex("$mask");
-
- my ($a, $b, $c, $d) = split('\.', $eucaconf{VNET_SUBNET});
- my $subnet = sprintf("0x%02x%02x%02x%02x", $a, $b, $c, $d);
- my $hexsubnet = hex("$subnet");
-
- foreach $group (keys(%secgroups)) {
- @ret = ();
- foreach $ip (keys( %{$secgroups{$group}})) {
- my ($a, $b, $c, $d) = split('\.', $ip);
- my $ipstr = sprintf("0x%02x%02x%02x%02x", $a, $b, $c, $d);
- my $hexip = hex("$ipstr");
- if ( ($hexsubnet & $hexmask) == ($hexmask & $hexip)) {
- my $line = sprintf ("host node-$ip {\n hardware ethernet D0:0D:%02x:%02x:%02x:%02x;\n fixed-address $ip;\n}\n", $a, $b, $c, $d);
- print DOFH "$line";
- }
- }
- }
- print DOFH "}\n";
- close(DOFH);
-
- return($retfile);
-}
-
-sub deploy_dhcpd() {
- my $dfile = shift @_;
- my $origfile = "$eucalyptus/var/run/eucalyptus/net/euca-dhcp.conf";
-
- # compare new with old
- if ( compare($dfile, $origfile) == 0) {
- return(0);
- }
-
- # kill if running
- my $pidfile = "$eucalyptus/var/run/eucalyptus/net/euca-dhcp.pid";
- if ( -f "$pidfile" ) {
- chomp(my $pid = `cat $pidfile`);
- kill(15, $pid);
- unlink($pidfile);
- }
- # remove trace
- unlink("$eucalyptus/var/run/eucalyptus/net/euca-dhcp.trace") || return(1);
-
- # touch leases
- open(LOFH, ">$eucalyptus/var/run/eucalyptus/net/euca-dhcp.leases");
- close(LOFH);
-
- # swap confs
- rename($dfile, $origfile) || return(1);
-
- # kick dhcpd
- return(system("$eucaconf{VNET_DHCPDAEMON} -cf $eucalyptus/var/run/eucalyptus/net/euca-dhcp.conf -lf $eucalyptus/var/run/eucalyptus/net/euca-dhcp.leases -pf $eucalyptus/var/run/eucalyptus/net/euca-dhcp.pid -tf $eucalyptus/var/run/eucalyptus/net/euca-dhcp.trace >/dev/null 2>&1 </dev/null"));
-}
-
-sub write_global_net() {
- $cmd = "wget -T 5 -t 1 -O $eucalyptus/var/log/eucalyptus/global-net -q http://$cloudip:8773/latest/network-topology";
- return(system($cmd));
-}
-
-sub check_environment() {
- if ($vnetmode ne "STATIC-DYNMAC") {
- exit(0);
- }
-
- $cmd = "ebtables -h >/dev/null 2>&1";
- if (system($cmd)) {
- print "ERROR: eucanetd: cannot run ebtables\n";
- return(1);
- }
-
- $cmd = "$iptpath/sbin/iptables -h >/dev/null 2>&1";
- if (system($cmd)) {
- print "ERROR: eucanetd: cannot run iptables\n";
- return(1);
- }
-
- if (!open(OFH, ">$logfile")) {
- print "ERROR: eucanetd: cannot write to logfile '$logfile'\n";
- return(1);
- }
- close(OFH);
-
- if (!open(OFH, ">$pidfile")) {
- print "ERROR: eucanetd: cannot write to pidfile '$pidfile'\n";
- return(1);
- }
- close(OFH);
-
- if ($dodhcpd) {
- unlink("$eucalyptus/var/run/eucalyptus/net/euca-dhcp.conf");
- }
- return(0);
-}
-
-sub parse_eucalyptus_conf() {
-
- if ( ! -f "$eucalyptus/etc/eucalyptus/eucalyptus.conf" ) {
- print "ERROR: eucanetd: cannot find config file '$eucalyptus/etc/eucalyptus/eucalyptus.conf'\n";
- return(1);
- }
-
-
- if (!open(FH, "$eucalyptus/etc/eucalyptus/eucalyptus.conf")) {
- print "ERROR: eucanetd: cannot open config file for read\n";
- return(1);
- }
-
- while(<FH>) {
- chomp;
- my $line = $_;
- if ($line =~ /\s*#.*/) {
- # skip comments
- } elsif ($line =~ /(.*)=(.*)/) {
- my $var = $1;
- my $val = $2;
- $val =~ s/"//g;
- $eucaconf{$var} = $val;
- if ($var eq "VNET_CLOUDIP") {
- $cloudip = "$val";
- }
- if ($var eq "EUCANETD_IPTPATH") {
- $iptpath = "$val";
- }
- if ($var eq "EUCANETD_IPTMODE") {
- $iptmode = "$val";
- }
- if ($var eq "EUCANETD_CLCPOLL") {
- $polltime = "$val";
- }
- if ($var eq "EUCANETD_DHCPDMODE") {
- $dodhcpd = "$val";
- }
- if ($var eq "VNET_MODE") {
- $vnetmode = "$val";
- }
- }
- }
- close(FH);
- return(0);
-}
-
-sub deploy_ebtrules() {
- my $file = shift @_;
- my $rc=1;
- if ( -f "$file" ) {
- $cmd = "ebtables --atomic-file $file --atomic-commit";
- $rc = system($cmd);
- } else {
- $rc = 0;
- }
- return($rc);
-}
-
-sub write_ebtrules() {
- my $afile = "/tmp/ebt.$$";
- my $fail;
- my @cmds;
-
- if (!$localpubdev || $localpubdev eq "") {
- return(0);
- }
-
- $cmd = "ebtables --atomic-file $afile --atomic-init";
- $rc = system($cmd);
- if ($rc) {
- return(1);
- }
- $cmd = "ebtables --atomic-file $afile -F FORWARD";
- $rc = system($cmd);
- if ($rc) {
- return(1);
- }
- $cmd = "ebtables --atomic-file $afile -P FORWARD ACCEPT";
- $rc = system($cmd);
- if ($rc) {
- return(1);
- }
-
-# @cmds = (@cmds, "FORWARD -i $localpubdev -j ACCEPT");
-# TODO: this next part needs to be more dynamic (xen vifs and ifaces)
-# @cmds = (@cmds, "FORWARD -i vif0.0 -j ACCEPT");
-# @cmds = (@cmds, "FORWARD -i peth0 -j ACCEPT");
-
-# @cmds = (@cmds, "FORWARD -p IPv4 --ip-dst $cloudip --ip-proto tcp --ip-dport 8773 -j ACCEPT");
- @cmds = (@cmds, "FORWARD -p IPv4 -d Broadcast --ip-proto udp --ip-dport 67:68 -j ACCEPT");
- @cmds = (@cmds, "FORWARD -p IPv4 -d Broadcast --ip-proto udp --ip-sport 67:68 -j ACCEPT");
- foreach $mac (keys (%localnets) ) {
- my %localnet = %{ $localnets{"$mac"} };
- my $ip = $localnet{privip};
- if ($ip ne "0.0.0.0") {
- my $erule = "FORWARD -i ! $localpubdev -p IPv4 -s $localnet{mac} --ip-src ! $ip -j DROP";
- @cmds = (@cmds, $erule);
- my $erule = "FORWARD -i ! $localpubdev -p IPv4 -s ! $localnet{mac} --ip-src $ip -j DROP";
- @cmds = (@cmds, $erule);
- }
-# my $erule = "FORWARD -i ! $localpubdev -s $localnet{mac} -j ACCEPT";
-# @cmds = (@cmds, $erule);
- }
-
- $fail=0;
- for $erule (@cmds) {
- $cmd = "ebtables --atomic-file $afile -A $erule";
- $rc = system($cmd);
- if ($rc) {
- $fail=1;
- }
- }
-
- if ($fail) {
- return("");
- }
- return($afile);
-}
-
-sub deploy_iptrules() {
- my $file = shift @_;
-
- my $rc = 1;
- if ( -f "$file" ) {
- my $cmd = "cat $file | $iptpath/sbin/iptables-restore > /dev/null 2>&1";
- $rc = system($cmd);
- }
- return($rc);
-}
-
-sub read_iptrules() {
- my $file = "/tmp/iptsave.$$";
-
- $cmd = "$iptpath/sbin/iptables-save > $file 2>/dev/null";
- $rc = system($cmd);
- if ($rc) {
- return("");
- }
- return($file);
-}
-
-sub write_iptrules() {
- my $file = "/tmp/iptrules.$$";
- if (!open(OFH, ">$file")) {
- return("");
- }
- print OFH "*nat\n";
- print OFH ":PREROUTING ACCEPT\n";
- print OFH ":POSTROUTING ACCEPT\n";
- print OFH ":OUTPUT ACCEPT\n";
- print OFH "-A PREROUTING -d 169.254.169.254 -p tcp --dport 80 -j DNAT --to-destination $cloudip:8773\n";
-# print OFH "-A OUTPUT -d 169.254.169.254 -p tcp --dport 80 -j DNAT --to-destination $cloudip:8773\n";
- print OFH "COMMIT\n";
- print OFH "*filter\n";
- print OFH ":INPUT ACCEPT\n";
- print OFH ":FORWARD ACCEPT\n";
- print OFH ":OUTPUT ACCEPT\n";
- print OFH ":ipsdrop - [0:0]\n";
- print OFH ":eucarules - [0:0]\n";
-# print OFH "-A PREROUTING -d 169.254.169.254 -p tcp --dport 80 -j DNAT --to-destination $cloudip:8773\n";
- print OFH "-A FORWARD -m conntrack --ctstate ESTABLISHED -j ACCEPT\n";
- print OFH "-A FORWARD -p udp -m udp --sport 67:68 --dport 67:68 -j LOG --log-level 6\n";
- print OFH "-A FORWARD -j eucarules\n";
-
- my %wgroups = ();
- my @localips = get_local_ips();
- for $localip (@localips) {
-# print OFH "-A FORWARD -s 192.168.7.30/32 -d $localip -j ACCEPT\n";
- my $group = get_my_group($localip);
- my @mygroupips = get_ips_by_group($group);
- if ($group ne "NOTFOUND") {
- if ($wgroups{$group} != 1) {
- print OFH ":$group - [0:0]\n";
- $wgroups{$group} = 1;
- }
- print OFH "-A ipsdrop -d $localip -j DROP\n";
- print OFH "-A eucarules -p udp -m udp --dport 67:68 -d $localip -j ACCEPT\n";
- # iptables way, or ipset way
- if ($iptmode eq "iptables") {
- for $ip (@mygroupips) {
- if ($ip ne $localip) {
- print OFH "-A $group -s $ip/32 -d $localip/32 -j ACCEPT\n";
- }
- }
- } elsif ($iptmode eq "ipset") {
-# $rc = make_ipset($group, @mygroupips);
-# if (open(ISOFH, ">/tmp/ipsets.$$")) {
-# system("ipset -X $group.stage >/dev/null 2>&1 </dev/null");
-# system("ipset -N $group iphash >/dev/null 2>&1 </dev/null");
-# print ISOFH "-N $group.stage iphash --hashsize 1024 --probes 8 --resize 50\n";
-# for $ip (@mygroupips) {
-# if ($ip ne $localip) {
-# print ISOFH "-A $group $ip\n";
-# }
-# }
-# print ISOFH "COMMIT\n";
-# close(ISOFH);
-# system("cat /tmp/ipsets.$$ | ipset --restore");
-# system("ipset --swap $group.stage $group");
-# system("ipset -X $group.stage");
-# unlink("/tmp/ipsets.$$");
-# }
- print OFH "-A $group -m set --set $group src,dst -d $localip -j ACCEPT\n";
- }
- print OFH "-A FORWARD -j $group\n";
-
- foreach $rule (keys( %{ $secrules{$group} } ) ) {
- my @iptrules = rule_convert($rule);
- foreach $iptrule (@iptrules) {
- print OFH "-A eucarules -d $localip $iptrule\n";
- }
- }
- }
- }
- print OFH "-A FORWARD -j ipsdrop\n";
- print OFH "COMMIT\n";
- close(OFH);
- return($file);
-}
-
-sub rule_convert() {
- my $rule = shift @_;
- my ($prot, $port, $source, $sourceuser, $sourcegroup);
- my $ret = "";
- my @retrules;
-
- if ($rule =~ /-P (\S+)/) {
- $prot = $1;
- }
- if ($rule =~ /-p (\S+)/) {
- $port = $1;
- $port =~ s/-/:/g;
- }
- if ($rule =~ /-s (\S+)/) {
- $source = $1;
- }
- if ($rule =~ /-u (\S+)/) {
- $sourceuser = "$1";
- }
- if ($rule =~ /-o (\S+)/) {
- $sourcegroup = "$1";
- }
- if ($sourceuser && $sourcegroup) {
- $source = "$sourceuser-$sourcegroup";
- }
-
- if ($source =~ /\d+\.\d+\.\d+\.\d+/) {
- if ($prot) {
- $ret .= "-p $prot ";
- }
- if ($port) {
- $ret .= "--dport $port ";
- }
- if ($source) {
- $ret .= "-s $source ";
- }
- $ret .= "-j ACCEPT";
- @retrules = (@retrules, $ret);
- } else {
- if ($iptmode eq "iptables") {
- my @ips = get_ips_by_group($source);
- for $ip (@ips) {
- $ret = "";
- if ($prot) {
- $ret .= "-p $prot ";
- }
- if ($port) {
- $ret .= "--dport $port ";
- }
- $ret .= "-s $ip ";
- @retrules = (@retrules, "$ret -j ACCEPT");
- }
- } elsif ($iptmode eq "ipset") {
- make_ipset($source);
- $ret = "-m set --set $source src,dst ";
- if ($prot) {
- $ret .= "-p $prot ";
- }
- if ($port) {
- $ret .= "--dport $port ";
- }
- @retrules = (@retrules, "$ret -j ACCEPT");
- }
- }
- return(@retrules);
-}
-
-sub get_local_ips() {
- my @ips = ();
- foreach $mac (keys(%localnets)) {
- @ips = (@ips, $localnets{"$mac"}{privip});
- }
-# return(keys(%localnets));
- return(@ips);
-}
-
-sub get_my_group() {
- my $ip = shift @_;
- foreach $group ( keys(%secgroups) ) {
- if ($secgroups{$group}{$ip} == 1) {
- return($group);
- }
- }
- return("NOTFOUND");
-}
-
-sub get_ips_by_group() {
- my $group = shift @_;
- my @ret;
-
- foreach $ip (keys( %{$secgroups{$group}})) {
- @ret = (@ret, $ip);
- }
- return(@ret);
-}
-
-sub print_local_net() {
-
- foreach $ip (keys (%localnets) ) {
- print LFH "$ip\n\t";
- my %localnet = %{ $localnets{"$ip"} };
- foreach $attr (keys (%localnet) ) {
- print LFH "$attr=$localnet{$attr} ";
- }
- print LFH "\n";
- }
- print LFH "\n";
-}
-
-sub print_global_net() {
- foreach $group (keys (%secgroups) ) {
- print LFH "$group\n";
- my %ips = %{ $secgroups{$group} };
- foreach $ip (keys(%ips)) {
- print LFH "\tIP=$ip\n";
- }
- my %rules = %{ $secrules{$group} };
- foreach $rule (keys(%rules)) {
- print LFH "\tRULE=$rule\n";
- }
- }
- print LFH "\n";
-}
-
-sub read_global_net() {
- open(FH, "$eucalyptus/var/log/eucalyptus/global-net");
- while(<FH>) {
- chomp;
- my $line = $_;
- if ($line) {
- my ($type, @tmp) = split(/\s+/, $line);
- if ($type eq "GROUP") {
- my ($type, @rest) = split(/\s+/, $line);
- my @ips = ();
- my $ipcount = 0;
- my $name = "";
- foreach $tok (@rest) {
- if ($tok =~ /\d+\.\d+\.\d+\.\d+/) {
- $ips[$ipcount] = $tok;
- $ipcount++;
- } else {
- $name .= $tok;
- }
- }
- for $ip (@ips) {
- $secgroups{$name}{$ip} = 1;
- }
- if ($iptmode eq "ipset") {
- $rc = make_ipset($name, @ips);
- }
- } elsif ($type eq "RULE") {
- my ($type, @rest) = split(/\s+/, $line);
- my @restarray = ();
- my $restcount = 0;
- my $name = "";
- my $tok = "";
- my $namemode = 1;
- foreach $tok (@rest) {
- if ($tok =~ /^-/) {
- $namemode = 0;
- }
- if ($namemode == 0) {
- $restarray[$restcount] = $tok;
- $restcount++;
- } else {
- $name .= $tok;
- }
- }
- my $rule = join(" ", @restarray);
- my %rules = $secrules{"$name"}{$rule} = 1;
- }
- }
- }
- close(FH);
- return(0);
-}
-
-sub read_local_net() {
- open(FH, "$eucalyptus/var/log/eucalyptus/local-net");
- while(<FH>) {
- chomp;
- my $line = $_;
- if ($line && $line !=~ /^\s*#/ ) {
- my ($id, $pubdev, $sec, $vlan, $mac, $pubip, $privip) = split(/\s+/, $line);
- if ($pubdev) {
- $localpubdev = $pubdev;
- }
- if ($privip && $mac) {
- my %tmp = ( 'pubdev' => $pubdev,
- 'sec' => $sec,
- 'vlan' => $vlan,
- 'mac' => $mac,
- 'pubip' => $pubip,
- 'privip' => $privip );
- $localnets{"$mac"} = { %tmp };
- }
- }
- }
- close(FH);
- return(0);
-}
-
-sub make_ipset() {
- my $group = shift @_;
- my @ips = @_;
- if (open(ISOFH, ">/tmp/ipsets.$$")) {
- system("ipset -X $group.stage >/dev/null 2>&1 </dev/null");
- system("ipset -N $group iphash >/dev/null 2>&1 </dev/null");
- print ISOFH "-N $group.stage iphash --hashsize 1024 --probes 8 --resize 50\n";
- for $ip (@ips) {
- if ($ip ne $localip) {
- print ISOFH "-A $group.stage $ip\n";
- }
- }
- print ISOFH "COMMIT\n";
- close(ISOFH);
- if (@ips) {
- system("cat /tmp/ipsets.$$ | ipset --restore");
- system("ipset --swap $group.stage $group");
- system("ipset -X $group.stage");
- }
- unlink("/tmp/ipsets.$$");
- } else {
- return(1);
- }
- return(0);
-}
View
BIN tools/floppy.moved
Binary file not shown.
View
33 tools/libvirt-kvm-windows-example.xml.moved
@@ -1,33 +0,0 @@
-<domain type='kvm'>
- <name>test</name>
- <os>
- <type>hvm</type>
- </os>
- <features>
- <acpi/>
- </features>
- <memory>524288</memory>
- <vcpu>1</vcpu>
- <devices>
- <emulator>/usr/bin/kvm</emulator>
- <disk type='file'>
- <source file='disk'/>
- <target dev='hda'/>
- </disk>
- <disk type='file' device='cdrom'>
- <source file='en_windows_server_2003_with_sp1_enterprise.iso'/>
- <target dev='hdc'/>
- <readonly/>
- </disk>
- <disk type='file' device='floppy'>
- <source file='floppy'/>
- <target dev='fda'/>
- </disk>
- <interface type='bridge'>
- <source bridge='br0'/>
- <mac address='d0:0d:3B:81:07:5D'/>
- <model type='rtl8139'/>
- </interface>
- <graphics type='vnc' port='-1' autoport='yes' listen='0.0.0.0'/>
- </devices>
-</domain>
View
47 tools/libvirt-xen-windows-example.xml.moved
@@ -1,47 +0,0 @@
-<domain type='xen'>
- <name>test</name>
- <os>
- <type>hvm</type>
- <loader>/usr/lib/xen/boot/hvmloader</loader>
- <boot dev='cdrom'/>
- </os>
- <features>
- <acpi/>
- <apic/>
- <pae/>
- </features>
- <clock offset='localtime'/>
- <on_poweroff>destroy</on_poweroff>
- <on_reboot>destroy</on_reboot>
- <on_crash>destroy</on_crash>
- <memory>524288</memory>
- <vcpu>1</vcpu>
- <devices>
- <emulator>/usr/lib64/xen/bin/qemu-dm</emulator>
- <disk type='file'>
- <source file='disk'/>
- <target dev='hda' bus='ide'/>
- </disk>
- <disk type='file' device='cdrom'>
- <source file='en_windows_server_2003_with_sp1_enterprise.iso'/>
- <target dev='hdc'/>
- <readonly/>
- </disk>
- <disk type='file' device='floppy'>
- <source file='floppy'/>
- <target dev='fda'/>
- </disk>
- <interface type='bridge'>
- <source bridge='xenbr0'/>
- <mac address='d0:0d:3F:5E:06:FB'/>
- <script path='/etc/xen/scripts/vif-bridge'/>
- </interface>
- <serial type='pty'>
- <source path='/dev/pts/3'/>
- <target port='0'/>
- </serial>
- <input type='tablet' bus='usb'/>
- <input type='mouse' bus='ps2'/>
- <graphics type='vnc' port='-1' autoport='yes' keymap='en-us' listen='0.0.0.0'/>
- </devices>
-</domain>
View
34 util/windows-bundle.c.moved
@@ -1,34 +0,0 @@
-#define _FILE_OFFSET_BITS 64 // so large-file support works on 32-bit systems
-#include <stdio.h>
-#include <stdlib.h>
-#define __USE_GNU
-#include <string.h> /* strlen, strcpy */
-#include <time.h>
-#include <limits.h> /* INT_MAX */
-#include <sys/types.h> /* fork */
-#include <sys/wait.h> /* waitpid */
-#include <unistd.h>
-#include <fcntl.h>
-#include <assert.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <pthread.h>
-#include <sys/vfs.h> /* statfs */
-#include <signal.h> /* SIGINT */
-#include <linux/limits.h>
-#ifndef MAX_PATH
-#define MAX_PATH 4096
-#endif
-
-#include <data.h>
-#include <windows-bundle.h>
-
-int allocate_bundleTask(bundleTask *out, char *instanceId, char *state) {
- if (out != NULL) {
- bzero(out, sizeof(bundleTask));
- if (instanceId) snprintf(out->instanceId, CHAR_BUFFER_SIZE, "%s", instanceId);
- if (state) snprintf(out->state, CHAR_BUFFER_SIZE, "%s", state);
- }
- return(0);
-}
-
View
16 util/windows-bundle.h.moved
@@ -1,16 +0,0 @@
-#ifndef INCLUDE_WINDOWS_BUNDLE_H
-#define INCLUDE_WINDOWS_BUNDLE_H
-
-#include <eucalyptus.h>
-#include <data.h>
-
-#define MAXBUNDLES MAXINSTANCES
-
-typedef struct bundleTask_t {
- char instanceId[CHAR_BUFFER_SIZE];
- char state[CHAR_BUFFER_SIZE];
-} bundleTask;
-
-int allocate_bundleTask(bundleTask *out, char *instanceId, char *state);
-
-#endif

0 comments on commit a1c25d5

Please sign in to comment.