# -*-shell-script-*- # This should be sourced by bash (though we welcome changes to make it POSIX sh compliant) # Monkeysphere authentication add-certifier subcommand # # This function adds a certifier whose signatures will be used to # calculate validity of keys used to connect to user accounts on the # server. The specified certifier key is first retrieved from the Web # of Trust with the monkeysphere-user-controlled gpg_sphere keyring. # Once then new key is retrieved, it is imported into the core # keyring. The gpg_core then ltsigns the key with the desired trust # level, and then the key is exported back to the gpg_sphere keyring. # The gpg_sphere has ultimate owner trust of the core key, so the core # ltsigs on the new certifier key can then be used by gpg_sphere # calculate validity for keys inserted in the authorized_keys file. # # This is all to keep the monkeysphere user that connects to the # keyservers from accessing the core secret key. # # The monkeysphere scripts are written by: # Jameson Rollins # Jamie McClelland # Daniel Kahn Gillmor # # They are Copyright 2008-2009, and are all released under the GPL, # version 3 or later. add_certifier() { local domain= local trust=full local depth=1 local keyID local fingerprint local ltsignCommand local trustval # get options while true ; do case "$1" in -n|--domain) domain="$2" shift 2 ;; -t|--trust) trust="$2" shift 2 ;; -d|--depth) depth="$2" shift 2 ;; -) break ;; *) if [ "$(echo "$1" | cut -c 1)" = '-' ] ; then failure "Unknown option '$1'. Type '$PGRM help' for usage." fi break ;; esac done keyID="$1" # check that key ID or file is specified if [ -z "$keyID" ] ; then failure "You must specify the key ID of a key to add, or specify a file to read the key from." fi # check the trust value case "$trust" in 'marginal') trustval=1 ;; 'full') trustval=2 ;; *) failure "Trust value requested ('$trust') was unclear (only 'marginal' or 'full' are supported)." ;; esac # if file is specified if [ -f "$keyID" -o "$keyID" = '-' ] ; then # load the key from stdin if [ "$keyID" = '-' ] ; then # make a temporary file to hold the key from stdin keyID=$(msmktempfile) trap "rm -f $keyID" EXIT log verbose "reading key from stdin..." cat > "$keyID" # load the key from the file elif [ -f "$keyID" ] ; then log verbose "reading key from file '$keyID'..." fi # check the key is ok as monkeysphere user before loading log debug "checking keys in file..." fingerprint=$(su_monkeysphere_user \ ". ${SYSSHAREDIR}/common; list_primary_fingerprints" < "$keyID") if [ $(printf "%s" "$fingerprint" | egrep -c '^[A-F0-9]{40}$') -ne 1 ] ; then failure "There was not exactly one gpg key in the file." fi # load the key gpg_sphere "--import" <"$keyID" 2>/dev/null \ || failure "could not read key from '$keyID'" # else, get the key from the keyserver else log verbose "searching keyserver $KEYSERVER for keyID $keyID..." gpg_sphere "--keyserver $KEYSERVER --recv-key '0x${keyID}!'" \ || failure "Could not receive a key with this ID from the '$KEYSERVER' keyserver." # get the full fingerprint of new certifier key log debug "getting fingerprint of certifier key..." fingerprint=$(gpg_sphere "--list-key --with-colons --with-fingerprint 0x${keyID}!" \ | grep '^fpr:' | cut -d: -f10) # test that there is only a single fingerprint if (( $(echo "$fingerprint" | wc -l) != 1 )) ; then cat <&2 read OK; OK=${OK:-Y} if [ "${OK/y/Y}" != 'Y' ] ; then failure "Identity certifier not added." fi else log debug "adding key without prompting." fi fi # export the key to the core keyring so that the core can sign the # new certifier key log debug "loading key into core keyring..." gpg_sphere "--export 0x${fingerprint}!" | gpg_core --import # edit-key script to ltsign key # NOTE: *all* user IDs will be ltsigned ltsignCommand="ltsign y $trustval $depth $domain y save" # end script # core ltsigns the newly imported certifier key log debug "executing core ltsign script..." if echo "$ltsignCommand" | \ gpg_core --command-fd 0 --edit-key "0x${fingerprint}!" ; then # transfer the new sigs back to the sphere keyring gpg_core_sphere_sig_transfer # update the sphere trustdb log debug "updating sphere trustdb..." gpg_sphere "--check-trustdb" 2>&1 | log debug log info "Identity certifier added." else failure "Problem adding identify certifier." fi } e fork):
  • # Copyright (c) 2005
  • #
  • # Author: DWS Systems Inc.
  • # Web: http://www.sql-ledger.org
  • #
  • #
  • #
  • # This program is free software; you can redistribute it and/or modify
  • # it under the terms of the GNU General Public License as published by
  • # the Free Software Foundation; either version 2 of the License, or
  • # (at your option) any later version.
  • #
  • # This program is distributed in the hope that it will be useful,
  • # but WITHOUT ANY WARRANTY; without even the implied warranty of
  • # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  • # GNU General Public License for more details.
  • # You should have received a copy of the GNU General Public License
  • # along with this program; if not, write to the Free Software
  • # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  • #======================================================================
  • #
  • # Job Costing module
  • #
  • #======================================================================
  • use LedgerSMB::JC;
  • 1;
  • # end of main
  • sub add {
  • if ($form->{type} eq 'timecard') {
  • $form->{title} = $locale->text('Add Time Card');
  • }
  • if ($form->{type} eq 'storescard') {
  • $form->{title} = $locale->text('Add Stores Card');
  • }
  • $form->{callback} = "$form->{script}?action=add&type=$form->{type}&login=$form->{login}&path=$form->{path}&sessionid=$form->{sessionid}&project=$form->{project}" unless $form->{callback};
  • &{ "prepare_$form->{type}" };
  • $form->{orphaned} = 1;
  • &display_form;
  • }
  • sub edit {
  • if ($form->{type} eq 'timecard') {
  • $form->{title} = $locale->text('Edit Time Card');
  • }
  • if ($form->{type} eq 'storescard') {
  • $form->{title} = $locale->text('Add Stores Card');
  • }
  • &{ "prepare_$form->{type}" };
  • &display_form;
  • }
  • sub jcitems_links {
  • if (@{ $form->{all_project} }) {
  • $form->{selectprojectnumber} = "<option>\n";
  • foreach $ref (@{ $form->{all_project} }) {
  • $form->{selectprojectnumber} .= qq|<option value="$ref->{projectnumber}--$ref->{id}">$ref->{projectnumber}\n|;
  • if ($form->{projectnumber} eq "$ref->{projectnumber}--$ref->{id}") {
  • $form->{projectdescription} = $ref->{description};
  • }
  • }
  • } else {
  • if ($form->{project} eq 'job') {
  • $form->error($locale->text('No open Jobs!'));
  • } else {
  • $form->error($locale->text('No open Projects!'));
  • }
  • }
  • if (@{ $form->{all_parts} }) {
  • $form->{selectpartnumber} = "<option>\n";
  • foreach $ref (@{ $form->{all_parts} }) {
  • $form->{selectpartnumber} .= qq|<option value="$ref->{partnumber}--$ref->{id}">$ref->{partnumber}\n|;
  • if ($form->{partnumber} eq "$ref->{partnumber}--$ref->{id}") {
  • if ($form->{partnumber} ne $form->{oldpartnumber}) {
  • for (qw(description unit sellprice pricematrix)) { $form->{$_} = $ref->{$_} }
  • }
  • }
  • }
  • } else {
  • if ($form->{type} eq 'timecard') {
  • if ($form->{project} eq 'job') {
  • $form->error($locale->text('No Labor codes on file!'));
  • } else {
  • $form->error($locale->text('No Services on file!'));
  • }
  • } else {
  • $form->error($locale->text('No Parts on file!'));
  • }
  • }
  • # employees
  • if (@{ $form->{all_employee} }) {
  • $form->{selectemployee} = "<option>\n";
  • for (@{ $form->{all_employee} }) { $form->{selectemployee} .= qq|<option value="$_->{name}--$_->{id}">$_->{name}\n| }
  • } else {
  • $form->error($locale->text('No Employees on file!'));
  • }
  • }
  • sub search {
  • # accounting years
  • $form->all_years(\%myconfig);
  • if (@{ $form->{all_years} }) {
  • $form->{selectaccountingyear} = "<option>\n";
  • for (@{ $form->{all_years} }) { $form->{selectaccountingyear} .= qq|<option>$_\n| }
  • $form->{selectaccountingmonth} = "<option>\n";
  • for (sort keys %{ $form->{all_month} }) { $form->{selectaccountingmonth} .= qq|<option value=$_>|.$locale->text($form->{all_month}{$_}).qq|\n| }
  • $selectfrom = qq|
  • <tr>
  • <th align=right>|.$locale->text('Period').qq|</th>
  • <td colspan=3>
  • <select name=month>$form->{selectaccountingmonth}</select>
  • <select name=year>$form->{selectaccountingyear}</select>
  • <input name=interval class=radio type=radio value=0 checked>&nbsp;|.$locale->text('Current').qq|
  • <input name=interval class=radio type=radio value=1>&nbsp;|.$locale->text('Month').qq|
  • <input name=interval class=radio type=radio value=3>&nbsp;|.$locale->text('Quarter').qq|
  • <input name=interval class=radio type=radio value=12>&nbsp;|.$locale->text('Year').qq|
  • </td>
  • </tr>
  • |;
  • }
  • $fromto = qq|
  • <tr>
  • <th align=right nowrap>|.$locale->text('Startdate').qq|</th>
  • <td>|.$locale->text('From').qq| <input name=startdatefrom size=11 title="$myconfig{dateformat}">
  • |.$locale->text('To').qq| <input name=startdateto size=11 title="$myconfig{dateformat}"></td>
  • </tr>
  • $selectfrom
  • |;
  • if ($form->{type} eq 'timecard') {
  • $form->{title} = $locale->text('Time Cards');
  • JC->jcitems_links(\%myconfig, \%$form);
  • }
  • if ($form->{type} eq 'storescard') {
  • $form->{title} = $locale->text('Stores Cards');
  • JC->jcitems_links(\%myconfig, \%$form);
  • }
  • if (@{ $form->{all_project} }) {
  • $form->{selectprojectnumber} = "<option>\n";
  • for (@{ $form->{all_project} }) { $form->{selectprojectnumber} .= qq|<option value="$_->{projectnumber}--$_->{id}">$_->{projectnumber}\n| }
  • }
  • if (@{ $form->{all_parts} }) {
  • $form->{selectpartnumber} = "<option>\n";
  • foreach $ref (@{ $form->{all_parts} }) {
  • $form->{selectpartnumber} .= qq|<option value="$ref->{partnumber}--$ref->{id}">$ref->{partnumber}\n|;
  • }
  • }
  • if ($form->{project} eq 'job') {
  • $joblabel = $locale->text('Job Number');
  • $laborlabel = $locale->text('Labor Code');
  • } elsif ($form->{project} eq 'project') {
  • $joblabel = $locale->text('Project Number');
  • $laborlabel = $locale->text('Service Code');
  • } else {
  • $joblabel = $locale->text('Project/Job Number');
  • $laborlabel = $locale->text('Service/Labor Code');
  • }
  • if ($form->{selectprojectnumber}) {
  • $jobnumber = qq|
  • <tr>
  • <th align=right nowrap>$joblabel</th>
  • <td colspan=3><select name=projectnumber>$form->{selectprojectnumber}</select></td>
  • </tr>
  • |;
  • }
  • if ($form->{type} eq 'timecard') {
  • # employees
  • if (@{ $form->{all_employee} }) {
  • $form->{selectemployee} = "<option>\n";
  • for (@{ $form->{all_employee} }) { $form->{selectemployee} .= qq|<option value="$_->{name}--$_->{id}">$_->{name}\n| }
  • } else {
  • $form->error($locale->text('No Employees on file!'));
  • }
  • if ($form->{selectpartnumber}) {
  • $partnumber = qq|
  • <tr>
  • <th align=right nowrap>$laborlabel</th>
  • <td colspan=3><select name=partnumber>$form->{selectpartnumber}</select></td>
  • </tr>
  • |;
  • }
  • $employee = qq|
  • <tr>
  • <th align=right nowrap>|.$locale->text('Employee').qq|</th>
  • <td colspan=3><select name=employee>$form->{selectemployee}</select></td>
  • </tr>
  • |;
  • $l_time = qq|<td nowrap><input name=l_time class=checkbox type=checkbox value=Y>&nbsp;|.$locale->text('Time').qq|</td>|;
  • }
  • $form->header;
  • print qq|
  • <body>
  • <form method=post action=$form->{script}>
  • <table width=100%>
  • <tr>
  • <th class=listtop>$form->{title}</th>
  • </tr>
  • <tr height="5"></tr>
  • <tr valign=top>
  • <td>
  • <table>
  • $jobnumber
  • $partnumber
  • $employee
  • $fromto
  • <tr>
  • <th align=right nowrap>|.$locale->text('Include in Report').qq|</th>
  • <td>
  • <table>
  • <tr>
  • <td nowrap><input name=open class=checkbox type=checkbox value=Y checked> |.$locale->text('Open').qq|</td>
  • <td nowrap><input name=closed class=checkbox type=checkbox value=Y> |.$locale->text('Closed').qq|</td>
  • </tr>
  • <tr>
  • $l_time
  • <td nowrap><input name=l_allocated class=checkbox type=checkbox value=Y> |.$locale->text('Allocated').qq|</td>
  • </tr>
  • <tr>
  • <td><input name=l_subtotal class=checkbox type=checkbox value=Y>&nbsp;|.$locale->text('Subtotal').qq|</td>
  • </tr>
  • </table>
  • </td>
  • </tr>
  • </table>
  • </td>
  • </tr>
  • <tr>
  • <td><hr size=3 noshade></td>
  • </tr>
  • </table>
  • <input type=hidden name=nextsub value="list_$form->{type}">
  • <input type=hidden name=sort value="transdate">
  • |;
  • $form->hide_form(qw(db path login sessionid project type));
  • print qq|
  • <br>
  • <input type=submit class=submit name=action value="|.$locale->text('Continue').qq|">
  • </form>
  • |;
  • if ($form->{menubar}) {
  • require "$form->{path}/menu.pl";
  • &menubar;
  • }
  • print qq|
  • </body>
  • </html>
  • |;
  • }
  • sub display_form {
  • &{ "$form->{type}_header" };
  • &{ "$form->{type}_footer" };
  • }
  • sub form_header {
  • &{ "$form->{type}_header" };
  • }
  • sub form_footer {
  • &{ "form->{type}_footer" };
  • }
  • sub prepare_timecard {
  • $form->{formname} = "timecard";
  • $form->{format} = "postscript" if $myconfig{printer};
  • $form->{media} = $myconfig{printer};
  • JC->get_jcitems(\%myconfig, \%$form);
  • $form->{selectformname} = qq|<option value="timecard">|.$locale->text('Time Card');
  • foreach $item (qw(in out)) {
  • ($form->{"${item}hour"}, $form->{"${item}min"}, $form->{"${item}sec"}) = split /:/, $form->{"checked$item"};
  • for (qw(hour min sec)) {