Download Managing Linux Systems with Webmin

Transcript
760
Chapter
60 • The Webmin API
function returns, the caller can read from or write to the handle to communicate with
a remote system, and call close on it when done. If the connection cannot be made,
the error function is called with a message explaining what went wrong, unless the
error parameter to this function has been set as a scalar reference. If so, the error
message is placed in that variable and the function returns 0 (instead of the usual
return value of 1).
other_groups(user) This returns a list of secondary groups to which the UNIX
user belongs.
PrintHeader([charset]) This outputs the Content-type:
text/html
header (and possibly others) that all CGI programs that produce HTML must
generate. If the charset parameter is given, it specifies the character set of the
HTML. This function is not generally called directly. Instead, the header function
will do it for you with the right character set for the user’s language.
progress_callback(action, details) This function exists to be passed to
http_download so that download progress reports will be printed. Calling it
directly from your code makes no sense.
put_miniserv_config(hashref) This writes the configuration from the hash
reference parameter hashref to the configuration file used by Webmin’s built-in
webserver. You will need to call restart_miniserv, however, for this change to
have any effect.
ReadParse() This function takes any CGI parameters passed to your program
(from form inputs or after the ? in the URL) and places them in the %in associative
array. If a CGI parameter has multiple values (for example, from a list that allows
multiple selections), then those values are separated by null characters (\0 in Perl).
ReadParseMime() When writing a CGI program that handles input from a form
using enctype=multipart/form-data, this function must be called instead of
ReadParse to fill the %in array with form inputs. You must add the enctype tag to
any forms using file-upload inputs.
read_acl([hashref1], [hashref2]) This function fetches the current list of
those to which the Webmin user has access and stores it in the hashes referenced by
the two parameters. hashref1 will be filled in as a two-key hash, in which the first
key is a username and the second a module name. hashref2 will be filled in with
usernames, each referring to an array of modules that the user has. For example:
&read_acl(\%hash1, \%hash2);
print "User $remote_user has access to Users and Groups<br>\n"
if ($hash1{$remote_user,'useradmin'});
print "User $remote_user has access to ",
join(" ", @{$hash2{$remote_user}}),"<br>\n";
read_env_file(file, hash)
This reads a file of /bin/sh variable assignments in key=value or key="value"
format into the given hash reference.