/* Copyright (C) 2010 Sergei Golubchik and Monty Program Ab Copyright(c)2010,2011,Oracleand/oritsaffiliates. Thisprogramisfreesoftware;youcanredistributeitand/or modifyitunderthetermsoftheGNUGeneralPublicLicenseas publishedbytheFreeSoftwareFoundation;version2ofthe License. Thisprogramisdistributedinthehopethatitwillbeuseful, butWITHOUTANYWARRANTY;withouteventheimpliedwarrantyof MERCHANTABILITYorFITNESSFORAPARTICULARPURPOSE.Seethe GNUGeneralPublicLicenseformoredetails. YoushouldhavereceivedacopyoftheGNUGeneralPublicLicense alongwiththisprogram;ifnot,writetotheFreeSoftware
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
/* no user name yet ? read the client handshake packet with the user name */ if (info->user_name == 0)
{ if (vio->read_packet(vio, &pkt) < 0) return CR_ERROR;
}
info->password_used= PASSWORD_USED_NO_MENTION;
vio->info(vio, &vio_info); if (vio_info.protocol != MYSQL_VIO_SOCKET) return CR_ERROR;
/* get the UID of the client process */ #ifdef HAVE_GETPEERUCRED if (getpeerucred(vio_info.socket, &cred) != 0) return CR_ERROR;
u = ucred_geteuid(cred);
ucred_free(cred); #else if (getsockopt(vio_info.socket, level, SO_PEERCRED, &cred, &cred_len)) return CR_ERROR;
if (cred_len != sizeof(cred)) return CR_ERROR;
u = cred.uid; #endif
/* and find the socket user name for this uid */
getpwuid_r(u, &pwd_buf, buf, sizeof(buf), &pwd); if (pwd == NULL) return CR_ERROR;
/* fill in the external user name used */
strncpy(info->external_user, pwd->pw_name, sizeof(info->external_user) - 1);
info->external_user[sizeof(info->external_user) - 1]= '\0';
/* compare with auth_string if it's defined, otherwise compare with DB user name*/ if (info->auth_string && info->auth_string[0]) return !strcmp(pwd->pw_name, info->auth_string) ? CR_OK : CR_ERROR; else return !strcmp(pwd->pw_name, info->user_name) ? CR_OK : CR_ERROR;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.