SANEI  1.0.27-151-gc6bfe88c-dirty
sanei_auth.h File Reference

Interface for authorization of resources. More...

Go to the source code of this file.


SANE_Status sanei_authorize (const char *resource, const char *backend, SANE_Auth_Callback authorize)
 Check authorization for a resource. More...

Detailed Description

Interface for authorization of resources.

This file implements an interface for user authorization. The authorization call is forwarded to the frontend which asks for a username and password. An MD5 digest is used if supported by the frontend.

See also
sanei.h sanei_backend.h

Function Documentation

◆ sanei_authorize()

SANE_Status sanei_authorize ( const char *  resource,
const char *  backend,
SANE_Auth_Callback  authorize 

Check authorization for a resource.

This function looks for the file SANE_CONFIG_DIR/backend.users. If this file doesn't exist, sanei_authorize always returns SANE_STATUS_GOOD. The file backend.users contains a list of usernames, passwords, and resources:

username:password:resource username:password:resource

If the requested resource isn't listed in this file, sanei_authorize return SANE_SATUS_GOOD. In all other cases, sanei_authorize sends a challenge to the frontend of the form


where randomstring consists of the PID, the time, and some random characters. It accepts two forms of answers

std: username:password md5: username:$MD5$m5digest

where md5digest is md5(randomstring password).

If this username/password/resource triple is listed in backend.users sanei_authorize returns SANE_STATUS_GOOD, in all other cases it returns SANE_STATUS_ACCESS_DENIED.

resourceresource to authorize
backendbackend name
authorizeauth callback
  • SANE_STATUS_GOOD - access is granted
  • SANE_STATUS_ACCESS_DENIED - access is denied