spacing and use Error instead of fprintf(stderr) so that things get logged.
This commit is contained in:
parent
e59eb510e3
commit
8de7d576a5
46
src/zmu.cpp
46
src/zmu.cpp
|
@ -426,11 +426,11 @@ int main(int argc, char *argv[]) {
|
|||
if ( config.opt_use_auth ) {
|
||||
if ( strcmp(config.auth_relay, "none") == 0 ) {
|
||||
if ( !checkUser(username)) {
|
||||
fprintf(stderr, "Error, username greater than allowed 32 characters\n");
|
||||
Error("Username greater than allowed 32 characters");
|
||||
exit_zmu(-1);
|
||||
}
|
||||
if ( !username ) {
|
||||
fprintf(stderr, "Error, username must be supplied\n");
|
||||
Error("Username must be supplied");
|
||||
exit_zmu(-1);
|
||||
}
|
||||
|
||||
|
@ -439,36 +439,32 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
} else {
|
||||
if ( !(username && password) && !auth ) {
|
||||
fprintf(stderr, "Error, username and password or auth string must be supplied\n");
|
||||
Error("Username and password or auth string must be supplied");
|
||||
exit_zmu(-1);
|
||||
}
|
||||
if ( !checkUser(username)) {
|
||||
fprintf(stderr, "Error, username greater than allowed 32 characters\n");
|
||||
Error("Username greater than allowed 32 characters");
|
||||
exit_zmu(-1);
|
||||
}
|
||||
if ( !checkPass(password)) {
|
||||
fprintf(stderr, "Error, password greater than allowed 64 characters\n");
|
||||
Error("Password greater than allowed 64 characters");
|
||||
exit_zmu(-1);
|
||||
}
|
||||
//if ( strcmp( config.auth_relay, "hashed" ) == 0 )
|
||||
{
|
||||
|
||||
if ( auth ) {
|
||||
user = zmLoadAuthUser(auth, false);
|
||||
}
|
||||
}
|
||||
//else if ( strcmp( config.auth_relay, "plain" ) == 0 )
|
||||
{
|
||||
if ( username && password ) {
|
||||
user = zmLoadUser(username, password);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // auth relay == none or not
|
||||
|
||||
if ( !user ) {
|
||||
fprintf(stderr, "Error, unable to authenticate user\n");
|
||||
return exit_zmu(-1);
|
||||
Error("Unable to authenticate user");
|
||||
exit_zmu(-1);
|
||||
}
|
||||
if ( !ValidateAccess(user, mon_id, function) ) {
|
||||
fprintf(stderr, "Error, insufficient privileges for requested action\n");
|
||||
Error("Insufficient privileges for requested action");
|
||||
exit_zmu(-1);
|
||||
}
|
||||
} // end if auth
|
||||
|
@ -524,18 +520,18 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
}
|
||||
if ( function & ZMU_WRITE_IDX ) {
|
||||
if ( verbose )
|
||||
if ( verbose ) {
|
||||
printf("Last write index: %d\n", monitor->GetLastWriteIndex());
|
||||
else {
|
||||
} else {
|
||||
if ( have_output ) printf("%c", separator);
|
||||
printf("%d", monitor->GetLastWriteIndex());
|
||||
have_output = true;
|
||||
}
|
||||
}
|
||||
if ( function & ZMU_EVENT ) {
|
||||
if ( verbose )
|
||||
if ( verbose ) {
|
||||
printf("Last event id: %" PRIu64 "\n", monitor->GetLastEventId());
|
||||
else {
|
||||
} else {
|
||||
if ( have_output ) printf("%c", separator);
|
||||
printf("%" PRIu64, monitor->GetLastEventId());
|
||||
have_output = true;
|
||||
|
@ -685,7 +681,7 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
delete monitor;
|
||||
} else {
|
||||
fprintf(stderr, "Error, invalid monitor id %d\n", mon_id);
|
||||
Error("Invalid monitor id %d", mon_id);
|
||||
exit_zmu(-1);
|
||||
}
|
||||
} else {
|
||||
|
@ -696,7 +692,7 @@ int main(int argc, char *argv[]) {
|
|||
printf("%s", vidString);
|
||||
exit_zmu(ok ? 0 : -1);
|
||||
#else // ZM_HAS_V4L
|
||||
fprintf( stderr, "Error, video4linux is required for device querying\n" );
|
||||
Error("Video4linux is required for device querying");
|
||||
exit_zmu(-1);
|
||||
#endif // ZM_HAS_V4L
|
||||
}
|
||||
|
@ -755,11 +751,11 @@ int main(int argc, char *argv[]) {
|
|||
0,
|
||||
0.0
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // end if function filter
|
||||
} // endif !user || canAccess(mon_id)
|
||||
} // end foreach row
|
||||
mysql_free_result(result);
|
||||
}
|
||||
} // end if function && ZMU_LIST
|
||||
}
|
||||
delete user;
|
||||
|
||||
|
|
Loading…
Reference in New Issue