--- projects/cms/source/ihost/libstatgrab/user_stats.c 2002/05/19 15:07:51 1.4
+++ projects/cms/source/ihost/libstatgrab/user_stats.c 2002/05/21 16:16:41 1.6
@@ -40,6 +40,7 @@ char *get_user_stats(){
#endif
#if defined(LINUX) || defined(SOLARIS)
+ setutent();
while((entry=getutent()) != NULL) {
if(entry->ut_type==USER_PROCESS) {
user_tmp=user_list;
@@ -52,6 +53,7 @@ char *get_user_stats(){
nousers++;
}
}
+ endutent();
#endif
#ifdef FREEBSD
@@ -78,8 +80,16 @@ char *get_user_stats(){
}
#endif
- if (user_list==NULL) user_list=strdup("");
- xml_user_data=strf("%s
%d",user_list,nousers);
+ if (user_list==NULL){
+ if((user_list=strdup("")) == NULL){
+ errf("strdup failed (%m)");
+ return NULL;
+ }
+ }
+ if((xml_user_data=strf("%s
%d",user_list,nousers)) == NULL){
+ errf("strf failed (%m)");
+ return NULL;
+ }
if (user_list!=NULL) free(user_list);
return xml_user_data;
}