Print this page
2989 Eliminate use of LOGNAME_MAX in ON
1166 useradd have warning with name more 8 chars


   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*


  22  * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
  23  */
  24 
  25 #include <sys/types.h>
  26 #include <sys/param.h>
  27 #include <stdio.h>
  28 #include <sys/fcntl.h>
  29 #include <stdlib.h>
  30 #include <string.h>
  31 #include <syslog.h>
  32 #include <unistd.h>
  33 
  34 #include <sys/socket.h>
  35 #include <sys/sockio.h>
  36 #include <netinet/in.h>
  37 #include <tsol/label.h>
  38 
  39 #include <bsm/audit.h>
  40 #include <bsm/audit_record.h>
  41 #include <bsm/audit_uevents.h>
  42 #include <bsm/libbsm.h>
  43 #include <bsm/audit_private.h>
  44 
  45 #include <locale.h>
  46 #include <pwd.h>
  47 #include <generic.h>
  48 
  49 #define BAD_PASSWD      (1)
  50 #define UNKNOWN_USER    (2)
  51 #define EXCLUDED_USER   (3)
  52 #define NO_ANONYMOUS    (4)
  53 #define MISC_FAILURE    (5)
  54 
  55 static char             luser[LOGNAME_MAX + 1];




  56 


  57 static void generate_record(char *, int, char *);
  58 static int selected(uid_t, char *, au_event_t, int);
  59 
  60 void
  61 audit_ftpd_bad_pw(char *uname)
  62 {
  63         if (cannot_audit(0)) {
  64                 return;
  65         }
  66         (void) strncpy(luser, uname, LOGNAME_MAX);
  67         generate_record(luser, BAD_PASSWD, dgettext(bsm_dom, "bad password"));
  68 }
  69 
  70 
  71 void
  72 audit_ftpd_unknown(char *uname)
  73 {
  74         if (cannot_audit(0)) {
  75                 return;
  76         }
  77         (void) strncpy(luser, uname, LOGNAME_MAX);
  78         generate_record(luser, UNKNOWN_USER, dgettext(bsm_dom, "unknown user"));
  79 }
  80 
  81 
  82 void
  83 audit_ftpd_excluded(char *uname)
  84 {
  85         if (cannot_audit(0)) {
  86                 return;
  87         }
  88         (void) strncpy(luser, uname, LOGNAME_MAX);
  89         generate_record(luser, EXCLUDED_USER, dgettext(bsm_dom,
  90             "excluded user"));
  91 }
  92 
  93 
  94 void
  95 audit_ftpd_no_anon(void)
  96 {
  97         if (cannot_audit(0)) {
  98                 return;
  99         }
 100         generate_record("", NO_ANONYMOUS, dgettext(bsm_dom, "no anonymous"));
 101 }
 102 
 103 void
 104 audit_ftpd_failure(char *uname)
 105 {
 106         if (cannot_audit(0)) {
 107                 return;
 108         }
 109         generate_record(uname, MISC_FAILURE, dgettext(bsm_dom, "misc failure"));
 110 }
 111 
 112 void
 113 audit_ftpd_success(char *uname)
 114 {
 115         if (cannot_audit(0)) {
 116                 return;
 117         }
 118         (void) strncpy(luser, uname, LOGNAME_MAX);
 119         generate_record(luser, 0, "");
 120 }
 121 
 122 
 123 
 124 static void
 125 generate_record(
 126                 char    *locuser,       /* username of local user */
 127                 int     err,            /* error status */
 128                                         /* (=0 success, >0 error code) */
 129                 char    *msg)           /* error message */
 130 {
 131         int     rd;             /* audit record descriptor */
 132         char    buf[256];       /* temporary buffer */
 133         uid_t   uid;
 134         gid_t   gid;
 135         uid_t   ruid;           /* real uid */
 136         gid_t   rgid;           /* real gid */
 137         pid_t   pid;
 138         struct passwd *pwd;




   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 2013 Gary Mills
  23  *
  24  * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
  25  */
  26 
  27 #include <sys/types.h>
  28 #include <sys/param.h>
  29 #include <stdio.h>
  30 #include <sys/fcntl.h>
  31 #include <stdlib.h>
  32 #include <string.h>
  33 #include <syslog.h>
  34 #include <unistd.h>
  35 
  36 #include <sys/socket.h>
  37 #include <sys/sockio.h>
  38 #include <netinet/in.h>
  39 #include <tsol/label.h>
  40 
  41 #include <bsm/audit.h>
  42 #include <bsm/audit_record.h>
  43 #include <bsm/audit_uevents.h>
  44 #include <bsm/libbsm.h>
  45 #include <bsm/audit_private.h>
  46 
  47 #include <locale.h>
  48 #include <pwd.h>
  49 #include <generic.h>
  50 
  51 #define BAD_PASSWD      (1)
  52 #define UNKNOWN_USER    (2)
  53 #define EXCLUDED_USER   (3)
  54 #define NO_ANONYMOUS    (4)
  55 #define MISC_FAILURE    (5)
  56 
  57 #ifdef  LOGNAME_MAX_ILLUMOS
  58 #define _LOGNAME_MAX    LOGNAME_MAX_ILLUMOS
  59 #else /* LOGNAME_MAX_ILLUMOS */
  60 #define _LOGNAME_MAX    LOGNAME_MAX
  61 #endif /* LOGNAME_MAX_ILLUMOS */
  62 
  63 static char             luser[_LOGNAME_MAX + 1];
  64 
  65 static void generate_record(char *, int, char *);
  66 static int selected(uid_t, char *, au_event_t, int);
  67 
  68 void
  69 audit_ftpd_bad_pw(char *uname)
  70 {
  71         if (cannot_audit(0)) {
  72                 return;
  73         }
  74         (void) strncpy(luser, uname, _LOGNAME_MAX);
  75         generate_record(luser, BAD_PASSWD, dgettext(bsm_dom, "bad password"));
  76 }
  77 
  78 
  79 void
  80 audit_ftpd_unknown(char *uname)
  81 {
  82         if (cannot_audit(0)) {
  83                 return;
  84         }
  85         (void) strncpy(luser, uname, _LOGNAME_MAX);
  86         generate_record(luser, UNKNOWN_USER, dgettext(bsm_dom, "unknown user"));
  87 }
  88 
  89 
  90 void
  91 audit_ftpd_excluded(char *uname)
  92 {
  93         if (cannot_audit(0)) {
  94                 return;
  95         }
  96         (void) strncpy(luser, uname, _LOGNAME_MAX);
  97         generate_record(luser, EXCLUDED_USER, dgettext(bsm_dom,
  98             "excluded user"));
  99 }
 100 
 101 
 102 void
 103 audit_ftpd_no_anon(void)
 104 {
 105         if (cannot_audit(0)) {
 106                 return;
 107         }
 108         generate_record("", NO_ANONYMOUS, dgettext(bsm_dom, "no anonymous"));
 109 }
 110 
 111 void
 112 audit_ftpd_failure(char *uname)
 113 {
 114         if (cannot_audit(0)) {
 115                 return;
 116         }
 117         generate_record(uname, MISC_FAILURE, dgettext(bsm_dom, "misc failure"));
 118 }
 119 
 120 void
 121 audit_ftpd_success(char *uname)
 122 {
 123         if (cannot_audit(0)) {
 124                 return;
 125         }
 126         (void) strncpy(luser, uname, _LOGNAME_MAX);
 127         generate_record(luser, 0, "");
 128 }
 129 
 130 
 131 
 132 static void
 133 generate_record(
 134                 char    *locuser,       /* username of local user */
 135                 int     err,            /* error status */
 136                                         /* (=0 success, >0 error code) */
 137                 char    *msg)           /* error message */
 138 {
 139         int     rd;             /* audit record descriptor */
 140         char    buf[256];       /* temporary buffer */
 141         uid_t   uid;
 142         gid_t   gid;
 143         uid_t   ruid;           /* real uid */
 144         gid_t   rgid;           /* real gid */
 145         pid_t   pid;
 146         struct passwd *pwd;