Changeset 206 for trunk/src/sh_prelude.c
- Timestamp:
- Jan 8, 2009, 10:08:45 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_prelude.c
r181 r206 696 696 int ret; 697 697 long port; 698 char *ptr, *new, *tmp, *ip, *srv, * end;698 char *ptr, *new, *tmp, *ip, *srv, *protocol, *end; 699 699 prelude_string_t *str; 700 700 idmef_address_t *address; … … 704 704 idmef_service_t *service; 705 705 idmef_source_t *source = idmef_alert_get_next_source(alert, NULL); 706 struct passwd *pw; 707 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 708 struct passwd pwd; 709 char buffer[SH_PWBUF_SIZE]; 710 #endif 706 711 707 712 new = sh_util_strdup(msg); … … 778 783 if ( *ptr && *end == '\0' && port >= 0 && port < 65536) { 779 784 785 char * tmpw; 786 780 787 if ( ! source ) { 781 788 ret = idmef_alert_new_source(alert, &source, IDMEF_LIST_APPEND); 782 789 if ( ret < 0 ) { 783 free(srv);784 790 SH_FREE( new ); 785 791 return ret; … … 789 795 ret = idmef_source_new_service(source, &service); 790 796 if ( ret < 0 ) { 791 free(srv);792 797 SH_FREE( new ); 793 798 return ret; … … 795 800 796 801 idmef_service_set_port(service, port); 802 803 ret = idmef_service_new_protocol(service, &str); 804 if ( ret < 0 ) { 805 SH_FREE( new ); 806 return ret; 807 } 808 809 ++tmp; 810 if (*tmp) { 811 char * tmpw = tmp; 812 char tmpw_store; 813 while (*tmpw && !isblank((int) *tmpw)) ++tmpw; 814 tmpw_store = *tmpw; *tmpw = '\0'; 815 protocol = strdup(tmp); 816 *tmpw = tmpw_store; 817 prelude_string_set_nodup(str, protocol); 818 } 819 797 820 } 798 821 … … 850 873 SH_FREE( new ); 851 874 852 ptr = get_value(msg, _("user "), NULL);875 ptr = get_value(msg, _("userid"), NULL); 853 876 854 877 if ( ptr ) { 855 878 879 idmef_user_id_t * user_id; 880 856 881 ret = idmef_source_new_user(source, &user); 857 882 if ( ret < 0 ) { … … 860 885 } 861 886 862 ret = idmef_user_new_ident(user, &str); 863 if ( ret < 0 ) { 864 free(ptr); 865 return ret; 866 } 887 idmef_user_set_category(user, IDMEF_USER_CATEGORY_APPLICATION); 888 889 ret = idmef_user_new_user_id(user, &user_id, IDMEF_LIST_APPEND); 890 if ( ret < 0 ) { 891 free(ptr); 892 return ret; 893 } 894 895 idmef_user_id_set_type(user_id, IDMEF_USER_ID_TYPE_CURRENT_USER); 896 897 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 898 sh_getpwnam_r(ptr, &pwd, buffer, sizeof(buffer), &pw); 899 #else 900 pw = sh_getpwnam(ptr); 901 #endif 902 if ( pw ) 903 idmef_user_id_set_number(user_id, pw->pw_uid); 904 905 ret = idmef_user_id_new_name(user_id, &str); 906 if ( ret < 0 ) { 907 free(ptr); 908 return ret; 909 } 867 910 prelude_string_set_nodup(str, ptr); 911 868 912 } 869 913 870 914 ptr = get_value(msg, _("path"), NULL); 915 tmp = get_value(msg, _("pid"), NULL); 871 916 872 917 if ( ptr ) { … … 889 934 prelude_string_set_nodup(str, ptr); 890 935 891 ptr = strrchr(ptr, '/');892 if ( ptr) {936 937 if ( NULL != strrchr(ptr, '/') ) { 893 938 ret = idmef_process_new_name(process, &str); 894 939 if ( ret == 0 ) { 940 ptr = strrchr(ptr, '/'); 895 941 prelude_string_set_dup(str, ptr + 1); 896 942 } 897 } 898 } 943 } else { 944 ret = idmef_process_new_name(process, &str); 945 if ( ret == 0 ) { 946 prelude_string_set_dup(str, ptr); 947 } 948 } 949 950 idmef_process_set_pid(process, strtoul(tmp, NULL, 0)); 951 } 952 953 if (tmp) 954 free(tmp); 899 955 900 956 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.