| 1 |
|
/* |
| 2 |
|
* i-scream central monitoring system |
| 3 |
+ |
* http://www.i-scream.org.uk |
| 4 |
|
* Copyright (C) 2000-2002 i-scream |
| 5 |
|
* |
| 6 |
|
* This program is free software; you can redistribute it and/or |
| 41 |
|
#endif |
| 42 |
|
|
| 43 |
|
#if defined(LINUX) || defined(SOLARIS) |
| 44 |
+ |
setutent(); |
| 45 |
|
while((entry=getutent()) != NULL) { |
| 46 |
|
if(entry->ut_type==USER_PROCESS) { |
| 47 |
|
user_tmp=user_list; |
| 54 |
|
nousers++; |
| 55 |
|
} |
| 56 |
|
} |
| 57 |
+ |
endutent(); |
| 58 |
|
#endif |
| 59 |
|
|
| 60 |
|
#ifdef FREEBSD |
| 74 |
|
if(user_tmp!=NULL) free(user_tmp); |
| 75 |
|
nousers++; |
| 76 |
|
} |
| 77 |
+ |
|
| 78 |
+ |
if ((fclose(f)) != 0) { |
| 79 |
+ |
errf("Failed to close file (%m)"); |
| 80 |
+ |
return NULL; |
| 81 |
+ |
} |
| 82 |
+ |
|
| 83 |
|
#endif |
| 84 |
< |
if (user_list==NULL) user_list=strdup(""); |
| 85 |
< |
xml_user_data=strf("<users><list>%s</list><count>%d</count></users>",user_list,nousers); |
| 84 |
> |
if (user_list==NULL){ |
| 85 |
> |
if((user_list=strdup("")) == NULL){ |
| 86 |
> |
errf("strdup failed (%m)"); |
| 87 |
> |
return NULL; |
| 88 |
> |
} |
| 89 |
> |
} |
| 90 |
> |
if((xml_user_data=strf("<users><list>%s</list><count>%d</count></users>",user_list,nousers)) == NULL){ |
| 91 |
> |
errf("strf failed (%m)"); |
| 92 |
> |
return NULL; |
| 93 |
> |
} |
| 94 |
|
if (user_list!=NULL) free(user_list); |
| 95 |
|
return xml_user_data; |
| 96 |
|
} |