mirror of
https://git.openldap.org/openldap/openldap.git
synced 2024-12-21 03:10:25 +08:00
Tweak back-ldif messages about CRC checksums.
This commit is contained in:
parent
06fe436053
commit
e25bce9124
@ -420,6 +420,7 @@ ldif_read_file( const char *path, char **datap )
|
|||||||
int res = -1; /* 0:success, <0:error, >0:file too big/growing. */
|
int res = -1; /* 0:success, <0:error, >0:file too big/growing. */
|
||||||
struct stat st;
|
struct stat st;
|
||||||
char *data = NULL, *ptr = NULL;
|
char *data = NULL, *ptr = NULL;
|
||||||
|
const char *msg;
|
||||||
|
|
||||||
if ( datap == NULL ) {
|
if ( datap == NULL ) {
|
||||||
res = stat( path, &st );
|
res = stat( path, &st );
|
||||||
@ -453,14 +454,13 @@ ldif_read_file( const char *path, char **datap )
|
|||||||
done:
|
done:
|
||||||
if ( res == 0 ) {
|
if ( res == 0 ) {
|
||||||
#ifdef LDAP_DEBUG
|
#ifdef LDAP_DEBUG
|
||||||
Debug( LDAP_DEBUG_TRACE, "ldif_read_file: %s: \"%s\"\n",
|
msg = "entry file exists";
|
||||||
datap ? "read entry file" : "entry file exists", path, 0 );
|
|
||||||
if ( datap ) {
|
if ( datap ) {
|
||||||
|
msg = "read entry file";
|
||||||
len = ptr - data;
|
len = ptr - data;
|
||||||
ptr = strstr( data, "\n# CRC32" );
|
ptr = strstr( data, "\n# CRC32" );
|
||||||
if (!ptr) {
|
if (!ptr) {
|
||||||
Debug( LDAP_DEBUG_TRACE, "ldif_read_file: no checksum \"%s\"\n",
|
msg = "read entry file without checksum";
|
||||||
path, 0, 0 );
|
|
||||||
} else {
|
} else {
|
||||||
unsigned int crc1 = 0, crc2 = 1;
|
unsigned int crc1 = 0, crc2 = 1;
|
||||||
if ( sscanf( ptr + 9, "%08x", &crc1) == 1) {
|
if ( sscanf( ptr + 9, "%08x", &crc1) == 1) {
|
||||||
@ -474,9 +474,11 @@ ldif_read_file( const char *path, char **datap )
|
|||||||
if ( crc1 != crc2 ) {
|
if ( crc1 != crc2 ) {
|
||||||
Debug( LDAP_DEBUG_ANY, "ldif_read_file: checksum error on \"%s\"\n",
|
Debug( LDAP_DEBUG_ANY, "ldif_read_file: checksum error on \"%s\"\n",
|
||||||
path, 0, 0 );
|
path, 0, 0 );
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Debug( LDAP_DEBUG_TRACE, "ldif_read_file: %s: \"%s\"\n", msg, path, 0 );
|
||||||
#endif /* LDAP_DEBUG */
|
#endif /* LDAP_DEBUG */
|
||||||
} else {
|
} else {
|
||||||
if ( res < 0 && errno == ENOENT ) {
|
if ( res < 0 && errno == ENOENT ) {
|
||||||
@ -484,7 +486,7 @@ ldif_read_file( const char *path, char **datap )
|
|||||||
"no entry file \"%s\"\n", path, 0, 0 );
|
"no entry file \"%s\"\n", path, 0, 0 );
|
||||||
rc = LDAP_NO_SUCH_OBJECT;
|
rc = LDAP_NO_SUCH_OBJECT;
|
||||||
} else {
|
} else {
|
||||||
const char *msg = res < 0 ? STRERROR( errno ) : "bad stat() size";
|
msg = res < 0 ? STRERROR( errno ) : "bad stat() size";
|
||||||
Debug( LDAP_DEBUG_ANY, "ldif_read_file: %s for \"%s\"\n",
|
Debug( LDAP_DEBUG_ANY, "ldif_read_file: %s for \"%s\"\n",
|
||||||
msg, path, 0 );
|
msg, path, 0 );
|
||||||
rc = LDAP_OTHER;
|
rc = LDAP_OTHER;
|
||||||
|
Loading…
Reference in New Issue
Block a user