Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixes EUCA-3962

Merge branch 'team/clc-dev/CHUCK-COVERITY-32' into maint/3.2/testing

Conflicts:
	util/sensor.c
  • Loading branch information...
commit e77086e1dae36cbc374ef1c2425bd34f4c2d8e24 2 parents d2c216a + 5e18cea
gelinasc gelinasc authored
75 gatherlog/GLclient.c
View
@@ -65,39 +65,46 @@
#include <gl-client-marshal.h>
#include <euca_auth.h>
-int main(int argc, char **argv) {
- axutil_env_t * env = NULL;
- axis2_char_t * client_home = NULL;
- axis2_char_t endpoint_uri[256], *tmpstr;
- axis2_stub_t * stub = NULL;
- int rc, i;
- char *euca_home;
-
- snprintf(endpoint_uri, 256," http://%s/axis2/services/EucalyptusGL", argv[1]);
- // env = axutil_env_create_all("/tmp/GLclient.log", AXIS2_LOG_LEVEL_TRACE);
- env = axutil_env_create_all("/tmp/fooh", AXIS2_LOG_LEVEL_TRACE);
- client_home = AXIS2_GETENV("AXIS2C_HOME");
- if (!client_home) {
- printf("must have AXIS2C_HOME set\n");
- }
- stub = axis2_stub_create_EucalyptusGL(env, client_home, endpoint_uri);
+int main(int argc, char **argv)
+{
+ axutil_env_t *env = NULL;
+ axis2_char_t *client_home = NULL;
+ axis2_char_t endpoint_uri[256], *tmpstr;
+ axis2_stub_t *stub = NULL;
+ int rc, i;
+ char *euca_home;
- if (!strcmp(argv[2], "getLogs")) {
- char *clog, *nlog, *hlog, *alog;
- rc = gl_getLogs(argv[3], &clog, &nlog, &hlog, &alog, env, stub);
- if (!rc) {
- if (clog) printf("CLOG\n----------\n%s\n-----------\n", base64_dec((unsigned char *)clog, strlen(clog)));
- if (nlog) printf("NLOG\n----------\n%s\n-----------\n", base64_dec((unsigned char *)nlog, strlen(nlog)));
- if (hlog) printf("HLOG\n----------\n%s\n-----------\n", base64_dec((unsigned char *)hlog, strlen(hlog)));
- if (alog) printf("ALOG\n----------\n%s\n-----------\n", base64_dec((unsigned char *)alog, strlen(alog)));
- }
- } else if (!strcmp(argv[2], "getKeys")) {
- char *cccert, *nccert;
- rc = gl_getKeys(argv[3], &cccert, &nccert, env, stub);
- if (!rc) {
- if (cccert) printf("CCCERT\n----------\n%s\n-----------\n", base64_dec((unsigned char *)cccert, strlen(cccert)));
- if (nccert) printf("NCCERT\n----------\n%s\n-----------\n", base64_dec((unsigned char *)nccert, strlen(nccert)));
- }
- }
- exit(0);
+ snprintf(endpoint_uri, 256, " http://%s/axis2/services/EucalyptusGL", argv[1]);
+ // env = axutil_env_create_all("/tmp/GLclient.log", AXIS2_LOG_LEVEL_TRACE);
+ env = axutil_env_create_all("/tmp/fooh", AXIS2_LOG_LEVEL_TRACE);
+ client_home = AXIS2_GETENV("AXIS2C_HOME");
+ if (!client_home) {
+ printf("must have AXIS2C_HOME set\n");
+ }
+ stub = axis2_stub_create_EucalyptusGL(env, client_home, endpoint_uri);
+
+ if (!strcmp(argv[2], "getLogs")) {
+ char *clog, *nlog, *hlog, *alog;
+ rc = gl_getLogs(argv[3], &clog, &nlog, &hlog, &alog, env, stub);
+ if (!rc) {
+ if (clog)
+ printf("CLOG\n----------\n%s\n-----------\n", base64_dec((unsigned char *)clog, strlen(clog)));
+ if (nlog)
+ printf("NLOG\n----------\n%s\n-----------\n", base64_dec((unsigned char *)nlog, strlen(nlog)));
+ if (hlog)
+ printf("HLOG\n----------\n%s\n-----------\n", base64_dec((unsigned char *)hlog, strlen(hlog)));
+ if (alog)
+ printf("ALOG\n----------\n%s\n-----------\n", base64_dec((unsigned char *)alog, strlen(alog)));
+ }
+ } else if (!strcmp(argv[2], "getKeys")) {
+ char *cccert, *nccert;
+ rc = gl_getKeys(argv[3], &cccert, &nccert, env, stub);
+ if (!rc) {
+ if (cccert)
+ printf("CCCERT\n----------\n%s\n-----------\n", base64_dec((unsigned char *)cccert, strlen(cccert)));
+ if (nccert)
+ printf("NCCERT\n----------\n%s\n-----------\n", base64_dec((unsigned char *)nccert, strlen(nccert)));
+ }
+ }
+ exit(0);
}
4 gatherlog/Makefile
View
@@ -121,6 +121,10 @@ deploy:
# no ws
$(INSTALL) $(DESTDIR)$(AXIS2C_SERVICES)/$(SERVICE_NAME)/services_noWS.xml $(DESTDIR)$(AXIS2C_SERVICES)/$(SERVICE_NAME)/services.xml
+indent:
+ @indent *.[ch] -nbad -bap -nbc -bbo -hnl -br -brs -c33 -cd33 -ncdb -ce -ci4 -cli0 -d0 -di1 -nfc1 -i4 -ut -ip0 -l200 -lp -npcs -nprs -npsl -sai -saf -saw -ncs -nsc -sob -nfca -ss -ts4 -il0 -nip
+ @\rm *.*~
+
clean:
rm -f $(SERVICE_SO) *.o $(CLIENT) *~* *#*
122 gatherlog/gl-client-marshal-adb.c
View
@@ -65,66 +65,68 @@
#include <gl-client-marshal.h>
#include <euca_auth.h>
-int gl_getLogs(char *service, char **outCClog, char **outNClog, char **outHlog, char **outAlog, axutil_env_t *env, axis2_stub_t *stub) {
- char *outservice;
-
- adb_GetLogsResponse_t *out;
- adb_getLogsResponseType_t *response;
-
- adb_GetLogs_t *in;
- adb_getLogsType_t *request;
-
- request = adb_getLogsType_create(env);
- adb_getLogsType_set_userId(request, env, "eucalyptus");
- adb_getLogsType_set_correlationId(request, env, "12345678");
- adb_getLogsType_set_serviceTag(request, env, service);
-
- in = adb_GetLogs_create(env);
- adb_GetLogs_set_GetLogs(in, env, request);
-
- out = axis2_stub_op_EucalyptusGL_GetLogs(stub, env, in);
- if (!out) {
- printf("ERROR: operation call failed\n");
- return(1);
- }
- response = adb_GetLogsResponse_get_GetLogsResponse(out, env);
-
- //outservice = adb_getLogsResponseType_get_serviceTag(response, env);
- *outCClog = adb_getLogsResponseType_get_CCLog(response, env);
- *outNClog = adb_getLogsResponseType_get_NCLog(response, env);
- *outHlog = adb_getLogsResponseType_get_httpdLog(response, env);
- *outAlog = adb_getLogsResponseType_get_axis2Log(response, env);
-
- return(0);
+int gl_getLogs(char *service, char **outCClog, char **outNClog, char **outHlog, char **outAlog, axutil_env_t * env, axis2_stub_t * stub)
+{
+ char *outservice;
+
+ adb_GetLogsResponse_t *out;
+ adb_getLogsResponseType_t *response;
+
+ adb_GetLogs_t *in;
+ adb_getLogsType_t *request;
+
+ request = adb_getLogsType_create(env);
+ adb_getLogsType_set_userId(request, env, "eucalyptus");
+ adb_getLogsType_set_correlationId(request, env, "12345678");
+ adb_getLogsType_set_serviceTag(request, env, service);
+
+ in = adb_GetLogs_create(env);
+ adb_GetLogs_set_GetLogs(in, env, request);
+
+ out = axis2_stub_op_EucalyptusGL_GetLogs(stub, env, in);
+ if (!out) {
+ printf("ERROR: operation call failed\n");
+ return (1);
+ }
+ response = adb_GetLogsResponse_get_GetLogsResponse(out, env);
+
+ //outservice = adb_getLogsResponseType_get_serviceTag(response, env);
+ *outCClog = adb_getLogsResponseType_get_CCLog(response, env);
+ *outNClog = adb_getLogsResponseType_get_NCLog(response, env);
+ *outHlog = adb_getLogsResponseType_get_httpdLog(response, env);
+ *outAlog = adb_getLogsResponseType_get_axis2Log(response, env);
+
+ return (0);
}
-int gl_getKeys(char *service, char **outCCCert, char **outNCCert, axutil_env_t *env, axis2_stub_t *stub) {
- char *outservice;
-
- adb_GetKeysResponse_t *out;
- adb_getKeysResponseType_t *response;
-
- adb_GetKeys_t *in;
- adb_getKeysType_t *request;
-
- request = adb_getKeysType_create(env);
- adb_getKeysType_set_userId(request, env, "eucalyptus");
- adb_getKeysType_set_correlationId(request, env, "12345678");
- adb_getKeysType_set_serviceTag(request, env, service);
-
- in = adb_GetKeys_create(env);
- adb_GetKeys_set_GetKeys(in, env, request);
-
- out = axis2_stub_op_EucalyptusGL_GetKeys(stub, env, in);
- if (!out) {
- printf("ERROR: operation call failed\n");
- return(1);
- }
- response = adb_GetKeysResponse_get_GetKeysResponse(out, env);
-
- //outservice = adb_getKeysResponseType_get_serviceTag(response, env);
- *outCCCert = adb_getKeysResponseType_get_CCcert(response, env);
- *outNCCert = adb_getKeysResponseType_get_NCcert(response, env);
-
- return(0);
+int gl_getKeys(char *service, char **outCCCert, char **outNCCert, axutil_env_t * env, axis2_stub_t * stub)
+{
+ char *outservice;
+
+ adb_GetKeysResponse_t *out;
+ adb_getKeysResponseType_t *response;
+
+ adb_GetKeys_t *in;
+ adb_getKeysType_t *request;
+
+ request = adb_getKeysType_create(env);
+ adb_getKeysType_set_userId(request, env, "eucalyptus");
+ adb_getKeysType_set_correlationId(request, env, "12345678");
+ adb_getKeysType_set_serviceTag(request, env, service);
+
+ in = adb_GetKeys_create(env);
+ adb_GetKeys_set_GetKeys(in, env, request);
+
+ out = axis2_stub_op_EucalyptusGL_GetKeys(stub, env, in);
+ if (!out) {
+ printf("ERROR: operation call failed\n");
+ return (1);
+ }
+ response = adb_GetKeysResponse_get_GetKeysResponse(out, env);
+
+ //outservice = adb_getKeysResponseType_get_serviceTag(response, env);
+ *outCCCert = adb_getKeysResponseType_get_CCcert(response, env);
+ *outNCCert = adb_getKeysResponseType_get_NCcert(response, env);
+
+ return (0);
}
4 gatherlog/gl-client-marshal.h
View
@@ -67,8 +67,8 @@
#include <time.h>
#include "axis2_stub_EucalyptusGL.h"
-int gl_getLogs(char *service, char **outCClog, char **outNClog, char **outHlog, char **outAlog, axutil_env_t *env, axis2_stub_t *stub);
+int gl_getLogs(char *service, char **outCClog, char **outNClog, char **outHlog, char **outAlog, axutil_env_t * env, axis2_stub_t * stub);
-int gl_getKeys(char *service, char **outCCCert, char **outNCCert, axutil_env_t *env, axis2_stub_t *stub);
+int gl_getKeys(char *service, char **outCCCert, char **outNCCert, axutil_env_t * env, axis2_stub_t * stub);
#endif
579 gatherlog/handlers.c
View
@@ -76,292 +76,307 @@
#include <eucalyptus.h>
-int doGetLogs(char *service, char **outCCLog, char **outNCLog, char **outHTTPDLog, char **outAxis2Log) {
- char *home, file[MAX_PATH], *buf;
- int fd, rc, bufsize;
-
- *outCCLog = *outNCLog = *outHTTPDLog = *outAxis2Log = NULL;
- if (!service) return(1);
-
- bufsize = 1000 * 1024;
- buf = malloc(bufsize);
- if (!buf) {
- printf("Out of memory!\n");
- return 1;
- }
-
- if (!strcmp(service, "self")) {
- char *tmp;
- home = NULL;
- tmp = getenv("EUCALYPTUS");
- if (tmp) home = strdup(tmp);
- if (!home) {
- home = strdup("");
- }
- if (!home) {
- printf("Out of memory!\n");
- free(buf);
- return 1;
- }
-
-
- snprintf(file, MAX_PATH, EUCALYPTUS_LOG_DIR "/cc.log", home);
- fd = open(file, O_RDONLY);
- if (fd >= 0) {
- bzero(buf, bufsize);
- lseek(fd, -1 * bufsize, SEEK_END);
- rc = read(fd, buf, bufsize);
- if (rc > 0) {
- *outCCLog = base64_enc((unsigned char *)buf, strlen(buf));
- }
- close(fd);
- } else {
- *outCCLog = NULL;
- }
-
- snprintf(file, MAX_PATH, EUCALYPTUS_LOG_DIR "/nc.log", home);
- fd = open(file, O_RDONLY);
- if (fd >= 0) {
- bzero(buf, bufsize);
- lseek(fd, -1 * bufsize, SEEK_END);
- rc = read(fd, buf, bufsize);
- if (rc > 0) {
- *outNCLog = base64_enc((unsigned char *)buf, strlen(buf));
- }
- close(fd);
- } else {
- *outNCLog = NULL;
- }
-
- bzero(buf, bufsize);
- snprintf(file, MAX_PATH, EUCALYPTUS_LOG_DIR "/httpd-nc_error_log", home);
- fd = open(file, O_RDONLY);
- if (fd < 0) {
- snprintf(file, MAX_PATH, EUCALYPTUS_LOG_DIR "/httpd-cc_error_log", home);
- fd = open(file, O_RDONLY);
- }
- if (fd >= 0) {
- bzero(buf, bufsize);
- rc = read(fd, buf, bufsize);
- if (rc > 0) {
- *outHTTPDLog = base64_enc((unsigned char *)buf, strlen(buf));
- }
- close(fd);
- } else {
- *outHTTPDLog = NULL;
- }
-
- bzero(buf, bufsize);
- snprintf(file, MAX_PATH, EUCALYPTUS_LOG_DIR "/axis2c.log", home);
- fd = open(file, O_RDONLY);
- if (fd >= 0) {
- bzero(buf, bufsize);
- rc = read(fd, buf, bufsize);
- if (rc > 0) {
- *outAxis2Log = base64_enc((unsigned char *)buf, strlen(buf));
- }
- close(fd);
- } else {
- *outAxis2Log = NULL;
- }
- if (home) free(home);
- } else {
- int pid, filedes[2], status;
-
- pipe(filedes);
- pid = fork();
- if (pid == 0) {
- axutil_env_t * env = NULL;
- axis2_char_t * client_home = NULL;
- axis2_char_t endpoint_uri[256], *tmpstr;
- axis2_stub_t * stub = NULL;
- char *clog, *hlog, *alog, *nlog;
-
- close(filedes[0]);
-
- // env = axutil_env_create_all("/tmp/GLclient.log", AXIS2_LOG_LEVEL_TRACE);
- env = axutil_env_create_all(NULL, 0);
- client_home = AXIS2_GETENV("AXIS2C_HOME");
- if (!client_home) {
- exit(1);
- } else {
- stub = axis2_stub_create_EucalyptusGL(env, client_home, service);
- clog = nlog = hlog = alog = NULL;
- rc = gl_getLogs("self", &clog, &nlog, &hlog, &alog, env, stub);
- if (rc) {
+int doGetLogs(char *service, char **outCCLog, char **outNCLog, char **outHTTPDLog, char **outAxis2Log)
+{
+ char *home, file[MAX_PATH], *buf;
+ int fd, rc, bufsize;
+
+ *outCCLog = *outNCLog = *outHTTPDLog = *outAxis2Log = NULL;
+ if (!service)
+ return (1);
+
+ bufsize = 1000 * 1024;
+ buf = malloc(bufsize);
+ if (!buf) {
+ printf("Out of memory!\n");
+ return 1;
+ }
+
+ if (!strcmp(service, "self")) {
+ char *tmp;
+ home = NULL;
+ tmp = getenv("EUCALYPTUS");
+ if (tmp)
+ home = strdup(tmp);
+ if (!home) {
+ home = strdup("");
+ }
+ if (!home) {
+ printf("Out of memory!\n");
+ free(buf);
+ return 1;
+ }
+
+ snprintf(file, MAX_PATH, EUCALYPTUS_LOG_DIR "/cc.log", home);
+ fd = open(file, O_RDONLY);
+ if (fd >= 0) {
+ bzero(buf, bufsize);
+ lseek(fd, -1 * bufsize, SEEK_END);
+ rc = read(fd, buf, bufsize);
+ if (rc > 0) {
+ *outCCLog = base64_enc((unsigned char *)buf, strlen(buf));
+ }
+ close(fd);
+ } else {
+ *outCCLog = NULL;
+ }
+
+ snprintf(file, MAX_PATH, EUCALYPTUS_LOG_DIR "/nc.log", home);
+ fd = open(file, O_RDONLY);
+ if (fd >= 0) {
+ bzero(buf, bufsize);
+ lseek(fd, -1 * bufsize, SEEK_END);
+ rc = read(fd, buf, bufsize);
+ if (rc > 0) {
+ *outNCLog = base64_enc((unsigned char *)buf, strlen(buf));
+ }
+ close(fd);
+ } else {
+ *outNCLog = NULL;
+ }
+
+ bzero(buf, bufsize);
+ snprintf(file, MAX_PATH, EUCALYPTUS_LOG_DIR "/httpd-nc_error_log", home);
+ fd = open(file, O_RDONLY);
+ if (fd < 0) {
+ snprintf(file, MAX_PATH, EUCALYPTUS_LOG_DIR "/httpd-cc_error_log", home);
+ fd = open(file, O_RDONLY);
+ }
+ if (fd >= 0) {
+ bzero(buf, bufsize);
+ rc = read(fd, buf, bufsize);
+ if (rc > 0) {
+ *outHTTPDLog = base64_enc((unsigned char *)buf, strlen(buf));
+ }
+ close(fd);
+ } else {
+ *outHTTPDLog = NULL;
+ }
+
+ bzero(buf, bufsize);
+ snprintf(file, MAX_PATH, EUCALYPTUS_LOG_DIR "/axis2c.log", home);
+ fd = open(file, O_RDONLY);
+ if (fd >= 0) {
+ bzero(buf, bufsize);
+ rc = read(fd, buf, bufsize);
+ if (rc > 0) {
+ *outAxis2Log = base64_enc((unsigned char *)buf, strlen(buf));
+ }
+ close(fd);
+ } else {
+ *outAxis2Log = NULL;
+ }
+ if (home)
+ free(home);
} else {
- bzero(buf, bufsize);
- if (clog) snprintf(buf, bufsize, "%s", clog);
- rc = write(filedes[1], buf, bufsize);
-
- bzero(buf, bufsize);
- if (nlog) snprintf(buf, bufsize, "%s", nlog);
- rc = write(filedes[1], buf, bufsize);
-
- bzero(buf, bufsize);
- if (hlog) snprintf(buf, bufsize, "%s", hlog);
- rc = write(filedes[1], buf, bufsize);
-
- bzero(buf, bufsize);
- if (alog) snprintf(buf, bufsize, "%s", alog);
- rc = write(filedes[1], buf, bufsize);
+ int pid, filedes[2], status;
+
+ pipe(filedes);
+ pid = fork();
+ if (pid == 0) {
+ axutil_env_t *env = NULL;
+ axis2_char_t *client_home = NULL;
+ axis2_char_t endpoint_uri[256], *tmpstr;
+ axis2_stub_t *stub = NULL;
+ char *clog, *hlog, *alog, *nlog;
+
+ close(filedes[0]);
+
+ // env = axutil_env_create_all("/tmp/GLclient.log", AXIS2_LOG_LEVEL_TRACE);
+ env = axutil_env_create_all(NULL, 0);
+ client_home = AXIS2_GETENV("AXIS2C_HOME");
+ if (!client_home) {
+ exit(1);
+ } else {
+ stub = axis2_stub_create_EucalyptusGL(env, client_home, service);
+ clog = nlog = hlog = alog = NULL;
+ rc = gl_getLogs("self", &clog, &nlog, &hlog, &alog, env, stub);
+ if (rc) {
+ } else {
+ bzero(buf, bufsize);
+ if (clog)
+ snprintf(buf, bufsize, "%s", clog);
+ rc = write(filedes[1], buf, bufsize);
+
+ bzero(buf, bufsize);
+ if (nlog)
+ snprintf(buf, bufsize, "%s", nlog);
+ rc = write(filedes[1], buf, bufsize);
+
+ bzero(buf, bufsize);
+ if (hlog)
+ snprintf(buf, bufsize, "%s", hlog);
+ rc = write(filedes[1], buf, bufsize);
+
+ bzero(buf, bufsize);
+ if (alog)
+ snprintf(buf, bufsize, "%s", alog);
+ rc = write(filedes[1], buf, bufsize);
+ }
+ }
+ close(filedes[1]);
+ exit(0);
+
+ } else {
+ close(filedes[1]);
+
+ bzero(buf, bufsize);
+ rc = read(filedes[0], buf, bufsize - 1);
+ if (rc && buf[0] != '\0') {
+ *outCCLog = strdup(buf);
+ }
+
+ bzero(buf, bufsize);
+ rc = read(filedes[0], buf, bufsize - 1);
+ if (rc && buf[0] != '\0') {
+ *outNCLog = strdup(buf);
+ }
+
+ bzero(buf, bufsize);
+ rc = read(filedes[0], buf, bufsize - 1);
+ if (rc && buf[0] != '\0') {
+ *outHTTPDLog = strdup(buf);
+ }
+
+ bzero(buf, bufsize);
+ rc = read(filedes[0], buf, bufsize - 1);
+ if (rc && buf[0] != '\0') {
+ *outAxis2Log = strdup(buf);
+ }
+ close(filedes[0]);
+ wait(&status);
+ }
}
- }
- close(filedes[1]);
- exit(0);
-
- } else {
- close(filedes[1]);
-
- bzero(buf, bufsize);
- rc = read(filedes[0], buf, bufsize - 1);
- if (rc && buf[0] != '\0') {
- *outCCLog = strdup(buf);
- }
-
- bzero(buf, bufsize);
- rc = read(filedes[0], buf, bufsize - 1);
- if (rc && buf[0] != '\0') {
- *outNCLog = strdup(buf);
- }
-
- bzero(buf, bufsize);
- rc = read(filedes[0], buf, bufsize - 1);
- if (rc && buf[0] != '\0') {
- *outHTTPDLog = strdup(buf);
- }
-
- bzero(buf, bufsize);
- rc = read(filedes[0], buf, bufsize - 1);
- if (rc && buf[0] != '\0') {
- *outAxis2Log = strdup(buf);
- }
- close(filedes[0]);
- wait(&status);
- }
- }
-
- if (buf) free(buf);
-
- return(0);
+
+ if (buf)
+ free(buf);
+
+ return (0);
}
-int doGetKeys(char *service, char **outCCCert, char **outNCCert) {
- char *home, file[MAX_PATH], *buf;
- int fd, rc, bufsize;
-
- *outCCCert = *outNCCert = NULL;
- if (!service) return(1);
-
-
- bufsize = 1000 * 1024;
- buf = malloc(bufsize);
- if (!buf) {
- printf("Out of memory!\n");
- return 1;
- }
-
- if (!strcmp(service, "self")) {
- char *tmp;
- home = NULL;
- tmp = getenv("EUCALYPTUS");
- if (tmp) home = strdup(tmp);
- if (!home) {
- home = strdup("");
- }
- if (!home) {
- printf("Out of memory!\n");
- free(buf);
- return 1;
- }
-
- snprintf(file, MAX_PATH, EUCALYPTUS_KEYS_DIR "/cluster-cert.pem", home);
- fd = open(file, O_RDONLY);
- if (fd >= 0) {
- bzero(buf, bufsize);
- lseek(fd, -1 * bufsize, SEEK_END);
- rc = read(fd, buf, bufsize);
- if (rc > 0) {
- *outCCCert = base64_enc((unsigned char *)buf, strlen(buf));
- }
- close(fd);
- } else {
- *outCCCert = NULL;
- }
-
- bzero(buf, bufsize);
- snprintf(file, MAX_PATH, EUCALYPTUS_KEYS_DIR "/node-cert.pem", home);
- fd = open(file, O_RDONLY);
- if (fd >= 0) {
- bzero(buf, bufsize);
- lseek(fd, -1 * bufsize, SEEK_END);
- // make sure that buf is NULL terminated
- rc = read(fd, buf, bufsize - 1);
- if (rc > 0) {
- *outNCCert = base64_enc((unsigned char *)buf, strlen(buf));
- }
- close(fd);
- } else {
- *outNCCert = NULL;
- }
-
- if (home) free(home);
- } else {
- int pid, filedes[2], status;
-
- pipe(filedes);
- pid = fork();
- if (pid == 0) {
- axutil_env_t * env = NULL;
- axis2_char_t * client_home = NULL;
- axis2_char_t endpoint_uri[256], *tmpstr;
- axis2_stub_t * stub = NULL;
- char *ccert, *ncert;
-
- close(filedes[0]);
-
- // env = axutil_env_create_all("/tmp/GLclient.log", AXIS2_LOG_LEVEL_TRACE);
- env = axutil_env_create_all(NULL, 0);
- client_home = AXIS2_GETENV("AXIS2C_HOME");
- if (!client_home) {
- exit(1);
- } else {
- stub = axis2_stub_create_EucalyptusGL(env, client_home, service);
- ccert = ncert = NULL;
- rc = gl_getKeys("self", &ccert, &ncert, env, stub);
- if (rc) {
+int doGetKeys(char *service, char **outCCCert, char **outNCCert)
+{
+ char *home, file[MAX_PATH], *buf;
+ int fd, rc, bufsize;
+
+ *outCCCert = *outNCCert = NULL;
+ if (!service)
+ return (1);
+
+ bufsize = 1000 * 1024;
+ buf = malloc(bufsize);
+ if (!buf) {
+ printf("Out of memory!\n");
+ return 1;
+ }
+
+ if (!strcmp(service, "self")) {
+ char *tmp;
+ home = NULL;
+ tmp = getenv("EUCALYPTUS");
+ if (tmp)
+ home = strdup(tmp);
+ if (!home) {
+ home = strdup("");
+ }
+ if (!home) {
+ printf("Out of memory!\n");
+ free(buf);
+ return 1;
+ }
+
+ snprintf(file, MAX_PATH, EUCALYPTUS_KEYS_DIR "/cluster-cert.pem", home);
+ fd = open(file, O_RDONLY);
+ if (fd >= 0) {
+ bzero(buf, bufsize);
+ lseek(fd, -1 * bufsize, SEEK_END);
+ rc = read(fd, buf, bufsize - 1);
+ if (rc > 0) {
+ *outCCCert = base64_enc((unsigned char *)buf, strlen(buf));
+ }
+ close(fd);
+ } else {
+ *outCCCert = NULL;
+ }
+
+ bzero(buf, bufsize);
+ snprintf(file, MAX_PATH, EUCALYPTUS_KEYS_DIR "/node-cert.pem", home);
+ fd = open(file, O_RDONLY);
+ if (fd >= 0) {
+ bzero(buf, bufsize);
+ lseek(fd, -1 * bufsize, SEEK_END);
+ // make sure that buf is NULL terminated
+ rc = read(fd, buf, bufsize - 1);
+ if (rc > 0) {
+ *outNCCert = base64_enc((unsigned char *)buf, strlen(buf));
+ }
+ close(fd);
+ } else {
+ *outNCCert = NULL;
+ }
+
+ if (home)
+ free(home);
} else {
- bzero(buf, bufsize);
- if (ccert) snprintf(buf, bufsize, "%s", ccert);
- rc = write(filedes[1], buf, bufsize);
-
- bzero(buf, bufsize);
- if (ncert) snprintf(buf, bufsize, "%s", ncert);
- rc = write(filedes[1], buf, bufsize);
+ int pid, filedes[2], status;
+
+ pipe(filedes);
+ pid = fork();
+ if (pid == 0) {
+ axutil_env_t *env = NULL;
+ axis2_char_t *client_home = NULL;
+ axis2_char_t endpoint_uri[256], *tmpstr;
+ axis2_stub_t *stub = NULL;
+ char *ccert, *ncert;
+
+ close(filedes[0]);
+
+ // env = axutil_env_create_all("/tmp/GLclient.log", AXIS2_LOG_LEVEL_TRACE);
+ env = axutil_env_create_all(NULL, 0);
+ client_home = AXIS2_GETENV("AXIS2C_HOME");
+ if (!client_home) {
+ exit(1);
+ } else {
+ stub = axis2_stub_create_EucalyptusGL(env, client_home, service);
+ ccert = ncert = NULL;
+ rc = gl_getKeys("self", &ccert, &ncert, env, stub);
+ if (rc) {
+ } else {
+ bzero(buf, bufsize);
+ if (ccert)
+ snprintf(buf, bufsize, "%s", ccert);
+ rc = write(filedes[1], buf, bufsize);
+
+ bzero(buf, bufsize);
+ if (ncert)
+ snprintf(buf, bufsize, "%s", ncert);
+ rc = write(filedes[1], buf, bufsize);
+ }
+ }
+ close(filedes[1]);
+ exit(0);
+
+ } else {
+ close(filedes[1]);
+ bzero(buf, bufsize);
+
+ rc = read(filedes[0], buf, bufsize - 1);
+ if (rc) {
+ *outCCCert = strdup(buf);
+ }
+
+ rc = read(filedes[0], buf, bufsize - 1);
+ if (rc) {
+ *outNCCert = strdup(buf);
+ }
+
+ close(filedes[0]);
+ wait(&status);
+ }
}
- }
- close(filedes[1]);
- exit(0);
-
- } else {
- close(filedes[1]);
-
- rc = read(filedes[0], buf, bufsize);
- if (rc) {
- *outCCCert = strdup(buf);
- }
-
- rc = read(filedes[0], buf, bufsize);
- if (rc) {
- *outNCCert = strdup(buf);
- }
-
- close(filedes[0]);
- wait(&status);
- }
- }
-
- if (buf) free(buf);
-
- return(0);
+
+ if (buf)
+ free(buf);
+
+ return (0);
}
192 gatherlog/server-marshal.c
View
@@ -66,92 +66,112 @@
#include <server-marshal.h>
-adb_GetLogsResponse_t *GetLogsMarshal(adb_GetLogs_t *getLogs, const axutil_env_t *env) {
- adb_GetLogsResponse_t *ret=NULL;
- adb_getLogsResponseType_t *response=NULL;
-
- adb_getLogsType_t *request=NULL;
-
- int rc;
- axis2_bool_t status;
- char *userId, *correlationId, *service, statusMessage[256];
- char *outCCLog, *outNCLog, *outHTTPDLog, *outAxis2Log;
-
- request = adb_GetLogs_get_GetLogs(getLogs, env);
-
- userId = adb_getLogsType_get_userId(request, env);
- correlationId = adb_getLogsType_get_correlationId(request, env);
- service = adb_getLogsType_get_serviceTag(request, env);
-
- response = adb_getLogsResponseType_create(env);
-
- status = AXIS2_TRUE;
- rc = doGetLogs(service, &outCCLog, &outNCLog, &outHTTPDLog, &outAxis2Log);
- if (rc) {
- status = AXIS2_FALSE;
- snprintf(statusMessage, 255, "ERROR");
- } else {
-
- if (outCCLog) {adb_getLogsResponseType_set_CCLog(response, env, outCCLog);free(outCCLog);}
- if (outNCLog) {adb_getLogsResponseType_set_NCLog(response, env, outNCLog);free(outNCLog);}
- if (outHTTPDLog) {adb_getLogsResponseType_set_httpdLog(response, env, outHTTPDLog);free(outHTTPDLog);}
- if (outAxis2Log) {adb_getLogsResponseType_set_axis2Log(response, env, outAxis2Log);free(outAxis2Log);}
- }
- adb_getLogsResponseType_set_serviceTag(response, env, service);
-
- adb_getLogsResponseType_set_userId(response, env, userId);
- adb_getLogsResponseType_set_correlationId(response, env, correlationId);
- adb_getLogsResponseType_set_return(response, env, status);
- if (status == AXIS2_FALSE) {
- adb_getLogsResponseType_set_statusMessage(response, env, statusMessage);
- }
-
- ret = adb_GetLogsResponse_create(env);
- adb_GetLogsResponse_set_GetLogsResponse(ret, env, response);
-
- return(ret);
+adb_GetLogsResponse_t *GetLogsMarshal(adb_GetLogs_t * getLogs, const axutil_env_t * env)
+{
+ adb_GetLogsResponse_t *ret = NULL;
+ adb_getLogsResponseType_t *response = NULL;
+
+ adb_getLogsType_t *request = NULL;
+
+ int rc;
+ axis2_bool_t status;
+ char *userId, *correlationId, *service, statusMessage[256];
+ char *outCCLog, *outNCLog, *outHTTPDLog, *outAxis2Log;
+
+ request = adb_GetLogs_get_GetLogs(getLogs, env);
+
+ userId = adb_getLogsType_get_userId(request, env);
+ correlationId = adb_getLogsType_get_correlationId(request, env);
+ service = adb_getLogsType_get_serviceTag(request, env);
+
+ response = adb_getLogsResponseType_create(env);
+
+ status = AXIS2_TRUE;
+ rc = doGetLogs(service, &outCCLog, &outNCLog, &outHTTPDLog, &outAxis2Log);
+ if (rc) {
+ status = AXIS2_FALSE;
+ snprintf(statusMessage, 255, "ERROR");
+ } else {
+
+ if (outCCLog) {
+ adb_getLogsResponseType_set_CCLog(response, env, outCCLog);
+ free(outCCLog);
+ }
+ if (outNCLog) {
+ adb_getLogsResponseType_set_NCLog(response, env, outNCLog);
+ free(outNCLog);
+ }
+ if (outHTTPDLog) {
+ adb_getLogsResponseType_set_httpdLog(response, env, outHTTPDLog);
+ free(outHTTPDLog);
+ }
+ if (outAxis2Log) {
+ adb_getLogsResponseType_set_axis2Log(response, env, outAxis2Log);
+ free(outAxis2Log);
+ }
+ }
+ adb_getLogsResponseType_set_serviceTag(response, env, service);
+
+ adb_getLogsResponseType_set_userId(response, env, userId);
+ adb_getLogsResponseType_set_correlationId(response, env, correlationId);
+ adb_getLogsResponseType_set_return(response, env, status);
+ if (status == AXIS2_FALSE) {
+ adb_getLogsResponseType_set_statusMessage(response, env, statusMessage);
+ }
+
+ ret = adb_GetLogsResponse_create(env);
+ adb_GetLogsResponse_set_GetLogsResponse(ret, env, response);
+
+ return (ret);
}
-adb_GetKeysResponse_t *GetKeysMarshal(adb_GetKeys_t *getKeys, const axutil_env_t *env) {
- adb_GetKeysResponse_t *ret=NULL;
- adb_getKeysResponseType_t *response=NULL;
-
- adb_getKeysType_t *request=NULL;
-
- int rc;
- axis2_bool_t status;
- char *userId, *correlationId, *service, statusMessage[256];
- char *outCCCert, *outNCCert;
-
- request = adb_GetKeys_get_GetKeys(getKeys, env);
-
- userId = adb_getKeysType_get_userId(request, env);
- correlationId = adb_getKeysType_get_correlationId(request, env);
- service = adb_getKeysType_get_serviceTag(request, env);
-
- response = adb_getKeysResponseType_create(env);
-
- status = AXIS2_TRUE;
- rc = doGetKeys(service, &outCCCert, &outNCCert);
- if (rc) {
- status = AXIS2_FALSE;
- snprintf(statusMessage, 255, "ERROR");
- } else {
- if (outCCCert) {adb_getKeysResponseType_set_CCcert(response, env, outCCCert);free(outCCCert);}
- if (outNCCert) {adb_getKeysResponseType_set_NCcert(response, env, outNCCert);free(outNCCert);}
- }
-
- adb_getKeysResponseType_set_userId(response, env, userId);
- adb_getKeysResponseType_set_correlationId(response, env, correlationId);
- adb_getKeysResponseType_set_return(response, env, status);
- adb_getKeysResponseType_set_serviceTag(response, env, service);
-
- if (status == AXIS2_FALSE) {
- adb_getKeysResponseType_set_statusMessage(response, env, statusMessage);
- }
-
- ret = adb_GetKeysResponse_create(env);
- adb_GetKeysResponse_set_GetKeysResponse(ret, env, response);
-
- return(ret);
+adb_GetKeysResponse_t *GetKeysMarshal(adb_GetKeys_t * getKeys, const axutil_env_t * env)
+{
+ adb_GetKeysResponse_t *ret = NULL;
+ adb_getKeysResponseType_t *response = NULL;
+
+ adb_getKeysType_t *request = NULL;
+
+ int rc;
+ axis2_bool_t status;
+ char *userId, *correlationId, *service, statusMessage[256];
+ char *outCCCert, *outNCCert;
+
+ request = adb_GetKeys_get_GetKeys(getKeys, env);
+
+ userId = adb_getKeysType_get_userId(request, env);
+ correlationId = adb_getKeysType_get_correlationId(request, env);
+ service = adb_getKeysType_get_serviceTag(request, env);
+
+ response = adb_getKeysResponseType_create(env);
+
+ status = AXIS2_TRUE;
+ rc = doGetKeys(service, &outCCCert, &outNCCert);
+ if (rc) {
+ status = AXIS2_FALSE;
+ snprintf(statusMessage, 255, "ERROR");
+ } else {
+ if (outCCCert) {
+ adb_getKeysResponseType_set_CCcert(response, env, outCCCert);
+ free(outCCCert);
+ }
+ if (outNCCert) {
+ adb_getKeysResponseType_set_NCcert(response, env, outNCCert);
+ free(outNCCert);
+ }
+ }
+
+ adb_getKeysResponseType_set_userId(response, env, userId);
+ adb_getKeysResponseType_set_correlationId(response, env, correlationId);
+ adb_getKeysResponseType_set_return(response, env, status);
+ adb_getKeysResponseType_set_serviceTag(response, env, service);
+
+ if (status == AXIS2_FALSE) {
+ adb_getKeysResponseType_set_statusMessage(response, env, statusMessage);
+ }
+
+ ret = adb_GetKeysResponse_create(env);
+ adb_GetKeysResponse_set_GetKeysResponse(ret, env, response);
+
+ return (ret);
}
4 gatherlog/server-marshal.h
View
@@ -66,7 +66,7 @@
#include "axis2_skel_EucalyptusGL.h"
#include <handlers.h>
-adb_GetLogsResponse_t *GetLogsMarshal(adb_GetLogs_t *getLogs, const axutil_env_t *env);
-adb_GetKeysResponse_t *GetKeysMarshal(adb_GetKeys_t *getKeys, const axutil_env_t *env);
+adb_GetLogsResponse_t *GetLogsMarshal(adb_GetLogs_t * getLogs, const axutil_env_t * env);
+adb_GetKeysResponse_t *GetKeysMarshal(adb_GetKeys_t * getKeys, const axutil_env_t * env);
#endif
5 net/vnetwork.c
View
@@ -2187,8 +2187,9 @@ int vnetApplyArpTableRules(vnetConfig *vnetconfig) {
if (vnetconfig->publicips[k].allocated && vnetconfig->publicips[k].dstip) {
char *ip=NULL;
ip = hex2dot(vnetconfig->publicips[k].dstip);
- if (ip && gw) {
- fprintf(FH, "IP=%s,%s\n", ip,gw);
+ if (ip) {
+ if(gw)
+ fprintf(FH, "IP=%s,%s\n", ip,gw);
free(ip);
}
}
16 node/NCclient.c
View
@@ -152,17 +152,17 @@ int add_vbr (const char * spec_str, virtualMachine * vm_type)
char * dev_spec = strtok (NULL, ":");
char * loc_spec = strtok (NULL, ":");
if (type_spec==NULL) { fprintf (stderr, "ERROR: invalid 'type' specification in VBR '%s'\n", spec_str); goto out_error; }
- strncpy (vbr->typeName, type_spec, sizeof (vbr->typeName));
+ safe_strncpy (vbr->typeName, type_spec, sizeof (vbr->typeName));
if (id_spec==NULL) { fprintf (stderr, "ERROR: invalid 'id' specification in VBR '%s'\n", spec_str); goto out_error; }
- strncpy (vbr->id, id_spec, sizeof (vbr->id));
+ safe_strncpy (vbr->id, id_spec, sizeof (vbr->id));
if (size_spec==NULL) { fprintf (stderr, "ERROR: invalid 'size' specification in VBR '%s'\n", spec_str); goto out_error; }
vbr->size = atoi (size_spec);
if (format_spec==NULL) { fprintf (stderr, "ERROR: invalid 'format' specification in VBR '%s'\n", spec_str); goto out_error; }
- strncpy (vbr->formatName, format_spec, sizeof (vbr->formatName));
+ safe_strncpy (vbr->formatName, format_spec, sizeof (vbr->formatName));
if (dev_spec==NULL) { fprintf (stderr, "ERROR: invalid 'guestDeviceName' specification in VBR '%s'\n", spec_str); goto out_error; }
- strncpy (vbr->guestDeviceName, dev_spec, sizeof (vbr->guestDeviceName));
+ safe_strncpy (vbr->guestDeviceName, dev_spec, sizeof (vbr->guestDeviceName));
if (loc_spec==NULL) { fprintf (stderr, "ERROR: invalid 'resourceLocation' specification in VBR '%s'\n", spec_str); goto out_error; }
- strncpy (vbr->resourceLocation, spec_str + (loc_spec - spec_copy), sizeof (vbr->resourceLocation));
+ safe_strncpy (vbr->resourceLocation, spec_str + (loc_spec - spec_copy), sizeof (vbr->resourceLocation));
free (spec_copy);
return 0;
@@ -361,9 +361,9 @@ int main (int argc, char **argv)
char walrus_url [BUFSIZE];
snprintf (walrus_url, BUFSIZE, "http://%s%s", walrus_hostport, WALRUS_ENDPOINT);
serviceInfoType * si = & (meta.services [meta.servicesLen++]);
- strncpy (si->type, "walrus", sizeof (si->type));
- strncpy (si->name, "walrus", sizeof (si->name));
- strncpy (si->uris[0], walrus_url, sizeof (si->uris[0]));
+ safe_strncpy (si->type, "walrus", sizeof (si->type));
+ safe_strncpy (si->name, "walrus", sizeof (si->name));
+ safe_strncpy (si->uris[0], walrus_url, sizeof (si->uris[0]));
si->urisLen = 1;
if (use_wssec && !local) {
1  node/handlers_kvm.c
View
@@ -329,6 +329,7 @@ doGetConsoleOutput( struct nc_state_t *nc,
if (rc < 0) {
logprintfl(EUCAERROR, "[%s] cannot seek to beginning of file\n", instanceId);
if (console_append) free(console_append);
+ close(fd);
return(1);
}
}
4 node/xml.c
View
@@ -127,7 +127,7 @@ static void init (struct nc_state_t * nc_state)
config_use_virtio_root = nc_state->config_use_virtio_root;
config_use_virtio_disk = nc_state->config_use_virtio_disk;
config_use_virtio_net = nc_state->config_use_virtio_net;
- strncpy (xslt_path, nc_state->libvirt_xslt_path, sizeof (xslt_path));
+ safe_strncpy (xslt_path, nc_state->libvirt_xslt_path, sizeof (xslt_path));
}
initialized = 1;
}
@@ -608,7 +608,7 @@ int main (int argc, char ** argv)
logprintfl (EUCAERROR, "required parameters are <XSLT stylesheet path>\n");
return 1;
}
- strncpy (xslt_path, argv[1], sizeof (xslt_path));
+ safe_strncpy (xslt_path, argv[1], sizeof (xslt_path));
char * in_path = tempnam (NULL, "xml-");
char * out_path = tempnam (NULL, "xml-");
10 storage/blobstore.c
View
@@ -492,7 +492,11 @@ static int open_and_lock (const char * path,
return -1;
}
}
- path_lock->refs++; // increase the reference count while still under lock
+ pthread_mutex_lock (&(path_lock->mutex)); // grab path-specific mutex
+ {
+ path_lock->refs++; // increase the reference count while still under lock
+ }
+ pthread_mutex_unlock (&(path_lock->mutex)); // release path-specific mutex
pthread_mutex_unlock (&_blobstore_mutex); // release global mutex
} // end of critical section
@@ -726,8 +730,8 @@ static int buf_to_fd (int fd, const char * buf, int size_buf)
static int read_store_metadata (blobstore * bs)
{
- char buf [1024];
- int size = fd_to_buf (bs->fd, buf, sizeof (buf));
+ char buf [1024] = { 0 };
+ int size = fd_to_buf (bs->fd, buf, (sizeof (buf) - 1));
if (size == -1)
return -1;
50 storage/vbr.c
View
@@ -254,7 +254,7 @@ parse_rec ( // parses the VBR as supplied by a client or user, checks values, an
logprintfl (EUCAWARN, "Warning: trimming off invalid prefix '/dev/' from guestDeviceName '%s'\n", vbr->guestDeviceName);
char buf [10];
safe_strncpy (buf, vbr->guestDeviceName + 5, sizeof (buf));
- strncpy (vbr->guestDeviceName, buf, sizeof (vbr->guestDeviceName));
+ safe_strncpy (vbr->guestDeviceName, buf, sizeof (vbr->guestDeviceName));
}
if (strlen (vbr->guestDeviceName)<3 ||
@@ -466,31 +466,31 @@ vbr_legacy ( // constructs VBRs for {image|kernel|ramdisk}x{Id|URL} entries (DEP
{ // create root partition VBR
virtualBootRecord * vbr = &(params->virtualBootRecord[i++]);
safe_strncpy (vbr->resourceLocation, imageURL, sizeof (vbr->resourceLocation));
- strncpy (vbr->guestDeviceName, "sda1", sizeof (vbr->guestDeviceName));
+ safe_strncpy (vbr->guestDeviceName, "sda1", sizeof (vbr->guestDeviceName));
safe_strncpy (vbr->id, imageId, sizeof (vbr->id));
- strncpy (vbr->typeName, "machine", sizeof (vbr->typeName));
+ safe_strncpy (vbr->typeName, "machine", sizeof (vbr->typeName));
vbr->size = -1;
- strncpy (vbr->formatName, "none", sizeof (vbr->formatName));
+ safe_strncpy (vbr->formatName, "none", sizeof (vbr->formatName));
params->virtualBootRecordLen++;
}
{ // create ephemeral partition VBR
virtualBootRecord * vbr = &(params->virtualBootRecord[i++]);
- strncpy (vbr->resourceLocation, "none", sizeof (vbr->resourceLocation));
- strncpy (vbr->guestDeviceName, "sda2", sizeof (vbr->guestDeviceName));
- strncpy (vbr->id, "none", sizeof (vbr->id));
- strncpy (vbr->typeName, "ephemeral0", sizeof (vbr->typeName));
+ safe_strncpy (vbr->resourceLocation, "none", sizeof (vbr->resourceLocation));
+ safe_strncpy (vbr->guestDeviceName, "sda2", sizeof (vbr->guestDeviceName));
+ safe_strncpy (vbr->id, "none", sizeof (vbr->id));
+ safe_strncpy (vbr->typeName, "ephemeral0", sizeof (vbr->typeName));
vbr->size = 524288; // we cannot compute it here, so pick something
- strncpy (vbr->formatName, "ext2", sizeof (vbr->formatName));
+ safe_strncpy (vbr->formatName, "ext2", sizeof (vbr->formatName));
params->virtualBootRecordLen++;
}
{ // create swap partition VBR
virtualBootRecord * vbr = &(params->virtualBootRecord[i++]);
- strncpy (vbr->resourceLocation, "none", sizeof (vbr->resourceLocation));
- strncpy (vbr->guestDeviceName, "sda3", sizeof (vbr->guestDeviceName));
- strncpy (vbr->id, "none", sizeof (vbr->id));
- strncpy (vbr->typeName, "swap", sizeof (vbr->typeName));
+ safe_strncpy (vbr->resourceLocation, "none", sizeof (vbr->resourceLocation));
+ safe_strncpy (vbr->guestDeviceName, "sda3", sizeof (vbr->guestDeviceName));
+ safe_strncpy (vbr->id, "none", sizeof (vbr->id));
+ safe_strncpy (vbr->typeName, "swap", sizeof (vbr->typeName));
vbr->size = 524288;
- strncpy (vbr->formatName, "swap", sizeof (vbr->formatName));
+ safe_strncpy (vbr->formatName, "swap", sizeof (vbr->formatName));
params->virtualBootRecordLen++;
}
}
@@ -507,12 +507,12 @@ vbr_legacy ( // constructs VBRs for {image|kernel|ramdisk}x{Id|URL} entries (DEP
return ERROR;
}
virtualBootRecord * vbr = &(params->virtualBootRecord[i++]);
- strncpy (vbr->resourceLocation, kernelURL, sizeof (vbr->resourceLocation));
- strncpy (vbr->guestDeviceName, "none", sizeof (vbr->guestDeviceName));
- strncpy (vbr->id, kernelId, sizeof (vbr->id));
- strncpy (vbr->typeName, "kernel", sizeof (vbr->typeName));
+ safe_strncpy (vbr->resourceLocation, kernelURL, sizeof (vbr->resourceLocation));
+ safe_strncpy (vbr->guestDeviceName, "none", sizeof (vbr->guestDeviceName));
+ safe_strncpy (vbr->id, kernelId, sizeof (vbr->id));
+ safe_strncpy (vbr->typeName, "kernel", sizeof (vbr->typeName));
vbr->size = -1;
- strncpy (vbr->formatName, "none", sizeof (vbr->formatName));
+ safe_strncpy (vbr->formatName, "none", sizeof (vbr->formatName));
params->virtualBootRecordLen++;
}
}
@@ -528,12 +528,12 @@ vbr_legacy ( // constructs VBRs for {image|kernel|ramdisk}x{Id|URL} entries (DEP
return ERROR;
}
virtualBootRecord * vbr = &(params->virtualBootRecord[i++]);
- strncpy (vbr->resourceLocation, ramdiskURL, sizeof (vbr->resourceLocation));
- strncpy (vbr->guestDeviceName, "none", sizeof (vbr->guestDeviceName));
- strncpy (vbr->id, ramdiskId, sizeof (vbr->id));
- strncpy (vbr->typeName, "ramdisk", sizeof (vbr->typeName));
+ safe_strncpy (vbr->resourceLocation, ramdiskURL, sizeof (vbr->resourceLocation));
+ safe_strncpy (vbr->guestDeviceName, "none", sizeof (vbr->guestDeviceName));
+ safe_strncpy (vbr->id, ramdiskId, sizeof (vbr->id));
+ safe_strncpy (vbr->typeName, "ramdisk", sizeof (vbr->typeName));
vbr->size = -1;
- strncpy (vbr->formatName, "none", sizeof (vbr->formatName));
+ safe_strncpy (vbr->formatName, "none", sizeof (vbr->formatName));
params->virtualBootRecordLen++;
}
}
@@ -1335,7 +1335,7 @@ static artifact * art_alloc_vbr (virtualBootRecord * vbr, boolean do_make_work_c
a2 = art_alloc (art_id, art_sig, a->size_bytes, !do_make_work_copy, must_be_file, FALSE, copy_creator, vbr);
if (a2) {
if (sshkey)
- strncpy (a2->sshkey, sshkey, sizeof (a2->sshkey)-1 );
+ safe_strncpy (a2->sshkey, sshkey, sizeof (a2->sshkey) );
if (art_add_dep (a2, a) == OK) {
a = a2;
5 util/fault.c
View
@@ -319,7 +319,7 @@ check_eucafault_suppression (const char *fault_id, const char *fault_file)
if (fault_file == NULL) {
// Degenerate case.
return is_suppressed_eucafault (fault_id);
- } else {
+ } else if (fault_id != NULL){
if (is_suppressed_eucafault (fault_id)) {
logprintfl (EUCATRACE, "Detected already-suppressed fault id %s\n", fault_id);
return TRUE;
@@ -354,8 +354,7 @@ check_eucafault_suppression (const char *fault_id, const char *fault_file)
return FALSE;
}
}
- logprintfl (EUCATRACE, "returning FALSE for %s, %s\n",
- fault_id, fault_file);
+ logprintfl (EUCATRACE, "returning FALSE for %s, %s\n", SP(fault_id), SP(fault_file));
return FALSE;
}
6 util/log.c
View
@@ -270,7 +270,7 @@ int log_file_set(const char * file)
if (strcmp (log_file_path, file) == 0) // hasn't changed
return 0;
- strncpy (log_file_path, file, EUCA_MAX_PATH);
+ safe_strncpy (log_file_path, file, EUCA_MAX_PATH);
if (get_file (TRUE) == NULL) {
return 1;
}
@@ -281,9 +281,9 @@ int log_file_set(const char * file)
int log_prefix_set (const char * log_spec)
{
if (log_spec==NULL || strlen (log_spec)==0) // TODO: eventually, enable empty prefix
- strncpy (log_custom_prefix, USE_STANDARD_PREFIX, sizeof (log_custom_prefix));
+ safe_strncpy (log_custom_prefix, USE_STANDARD_PREFIX, sizeof (log_custom_prefix));
else
- strncpy (log_custom_prefix, log_spec, sizeof (log_custom_prefix));
+ safe_strncpy (log_custom_prefix, log_spec, sizeof (log_custom_prefix));
return 0;
}
30 util/sensor.c
View
@@ -209,7 +209,7 @@ static int getstat_generate (getstat ***pstats)
for ( ; gsp->next != NULL; gsp = gsp->next); // walk the linked list to the end
gsp->next = gs; // add the new record
}
- strncpy (gs->instanceId, subtoken, sizeof (gs->instanceId));
+ safe_strncpy (gs->instanceId, subtoken, sizeof (gs->instanceId));
break;
}
case 2: {
@@ -223,13 +223,13 @@ static int getstat_generate (getstat ***pstats)
break;
}
case 3:
- strncpy (gs->metricName, subtoken, sizeof (gs->metricName));
+ safe_strncpy (gs->metricName, subtoken, sizeof (gs->metricName));
break;
case 4:
gs->counterType = sensor_str2type (subtoken);
break;
case 5:
- strncpy (gs->dimensionName, subtoken, sizeof (gs->dimensionName));
+ safe_strncpy (gs->dimensionName, subtoken, sizeof (gs->dimensionName));
break;
case 6: {
char * endptr;
@@ -298,8 +298,8 @@ static void sensor_bottom_half (void)
// refresh local copy of resource names & aliases
sem_p (state_sem);
for (int i=0; i<sensor_state->max_resources && i<MAX_SENSOR_RESOURCES; i++) {
- strncpy (resourceNames[i], sensor_state->resources[i].resourceName, MAX_SENSOR_NAME_LEN);
- strncpy (resourceAliases[i], sensor_state->resources[i].resourceAlias, MAX_SENSOR_NAME_LEN);
+ safe_strncpy (resourceNames[i], sensor_state->resources[i].resourceName, MAX_SENSOR_NAME_LEN);
+ safe_strncpy (resourceAliases[i], sensor_state->resources[i].resourceAlias, MAX_SENSOR_NAME_LEN);
if (strlen (resourceNames[i]) && strlen(resourceAliases[i])) {
logprintfl (EUCATRACE, "Found alias '%s' for resource '%s'\n",
resourceAliases[i], resourceNames[i]);
@@ -659,7 +659,7 @@ int sensor_get_dummy_instance_data (long long sn, const char * instanceId, const
assert (srsLen>0);
sensorResource * sr = srs[0];
memcpy (sr, &example, sizeof(sensorResource));
- strncpy (sr->resourceName, instanceId, sizeof(sr->resourceName));
+ safe_strncpy (sr->resourceName, instanceId, sizeof(sr->resourceName));
return 0;
}
@@ -705,11 +705,11 @@ static sensorResource * find_or_alloc_sr (const boolean do_alloc, const char * r
// fill out the new slot
if (unused_sr != NULL) {
bzero (unused_sr, sizeof (sensorResource));
- strncpy (unused_sr->resourceName, resourceName, sizeof (unused_sr->resourceName));
+ safe_strncpy (unused_sr->resourceName, resourceName, sizeof (unused_sr->resourceName));
if (resourceType)
- strncpy (unused_sr->resourceType, resourceType, sizeof (unused_sr->resourceType));
+ safe_strncpy (unused_sr->resourceType, resourceType, sizeof (unused_sr->resourceType));
if (resourceUuid)
- strncpy (unused_sr->resourceUuid, resourceUuid, sizeof (unused_sr->resourceUuid));
+ safe_strncpy (unused_sr->resourceUuid, resourceUuid, sizeof (unused_sr->resourceUuid));
sensor_state->used_resources++;
logprintfl (EUCADEBUG, "allocated new sensor resource %s\n", resourceName);
}
@@ -739,7 +739,7 @@ static sensorMetric * find_or_alloc_sm (const boolean do_alloc, sensorResource *
// fill out the new slot
sensorMetric * sm = sr->metrics + sr->metricsLen;
bzero (sm, sizeof (sensorMetric));
- strncpy (sm->metricName, metricName, sizeof (sm->metricName));
+ safe_strncpy (sm->metricName, metricName, sizeof (sm->metricName));
sr->metricsLen++;
logprintfl (EUCADEBUG, "allocated new sensor metric %s:%s\n", sr->resourceName, sm->metricName);
@@ -799,7 +799,7 @@ static sensorDimension * find_or_alloc_sd (const boolean do_alloc, sensorCounter
// fill out the new slot
sensorDimension * sd = sc->dimensions + sc->dimensionsLen;
bzero (sd, sizeof (sensorDimension));
- strncpy (sd->dimensionName, dimensionName, sizeof (sd->dimensionName));
+ safe_strncpy (sd->dimensionName, dimensionName, sizeof (sd->dimensionName));
sc->dimensionsLen++;
logprintfl (EUCADEBUG, "allocated new sensor dimension %s:%s\n", sensor_type2str(sc->type), sd->dimensionName);
@@ -1032,13 +1032,13 @@ int sensor_add_value (const char * instanceId,
}
}
};
- strncpy (sr.resourceName, instanceId, sizeof (sr.resourceName));
+ safe_strncpy (sr.resourceName, instanceId, sizeof (sr.resourceName));
sensorMetric * sm = sr.metrics; // use array entry [0]
- strncpy (sm->metricName, metricName, sizeof (sm->metricName));
+ safe_strncpy (sm->metricName, metricName, sizeof (sm->metricName));
sensorCounter * sc = sm->counters; // use array entry [0]
sc->type = counterType;
sensorDimension * sd = sc->dimensions; // use array entry [0]
- strncpy (sd->dimensionName, dimensionName, sizeof (sd->dimensionName));
+ safe_strncpy (sd->dimensionName, dimensionName, sizeof (sd->dimensionName));
sensorValue * sv = sd->values; // use array entry [0]
sv->timestampMs = timestampMs;
sv->value = value;
@@ -1484,7 +1484,7 @@ int main (int argc, char ** argv)
getstat * gs = getstat_find (stats, NULL);
if (gs != NULL) {
char id [MAX_SENSOR_NAME_LEN];
- strncpy (id, gs->instanceId, sizeof (id));
+ safe_strncpy (id, gs->instanceId, sizeof (id));
assert (sensor_refresh_resources (id, "", 1) == OK);
}
if (i%101 == 0 || i%102 == 0) {
Please sign in to comment.
Something went wrong with that request. Please try again.