From 9342d61cac6cfebd11a7cdb5dc1359d663c5d1a3 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 13 Mar 2004 00:16:24 +0000 Subject: fix suse document root --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index bd6019bc8..3c4683849 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ FREESIDE_DOCUMENT_ROOT = /var/www/freeside #openbsd #FREESIDE_DOCUMENT_ROOT = /var/www/htdocs/freeside #suse -#FREESIDE_DOCUMENT_ROOT = /srv/www/htdocs +#FREESIDE_DOCUMENT_ROOT = /srv/www/htdocs/freeside #deb, redhat, mandrake, suse, others? INIT_FILE = /etc/init.d/freeside -- cgit v1.2.1 From 02aea7237fa255266f7b71eb0a9114c12aa3c034 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 13 Mar 2004 00:50:41 +0000 Subject: automatically set Mason comp_root in Makefile --- Makefile | 4 ++++ htetc/handler.pl | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3c4683849..1b212b387 100644 --- a/Makefile +++ b/Makefile @@ -121,6 +121,10 @@ install-docs: docs [ "${TEMPLATE}" = "asp" ] && chown -R freeside ${ASP_GLOBAL} || true [ "${TEMPLATE}" = "asp" ] && cp htetc/global.asa ${ASP_GLOBAL} || true [ "${TEMPLATE}" = "mason" ] && cp htetc/handler.pl ${MASON_HANDLER} || true + [ "${TEMPLATE}" = "mason" ] && + perl -p -i -e "\ + s/%%%FREESIDE_DOCUMENT_ROOT%%%/${FREESIDE_DOCUMENT_ROOT}/g; + " ${MASON_HANDLER} [ "${TEMPLATE}" = "mason" -a ! -e ${MASONDATA} ] && mkdir ${MASONDATA} || true [ "${TEMPLATE}" = "mason" ] && chown -R freeside ${MASONDATA} || true diff --git a/htetc/handler.pl b/htetc/handler.pl index 0301d98d1..8541b4ce5 100644 --- a/htetc/handler.pl +++ b/htetc/handler.pl @@ -38,7 +38,7 @@ use strict; my $ah = new HTML::Mason::ApacheHandler ( #interp => $interp, #auto_send_headers => 0, - comp_root=>'/var/www/freeside', + comp_root=>'%%%FREESIDE_DOCUMENT_ROOT%%%', data_dir=>'/usr/local/etc/freeside/masondata', #out_mode=>'stream', ); -- cgit v1.2.1 From 0fd798c8ecec0141cdb4c5db2016a94ae34a24f2 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 13 Mar 2004 00:53:29 +0000 Subject: oops --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 1b212b387..f6f7ae516 100644 --- a/Makefile +++ b/Makefile @@ -123,7 +123,7 @@ install-docs: docs [ "${TEMPLATE}" = "mason" ] && cp htetc/handler.pl ${MASON_HANDLER} || true [ "${TEMPLATE}" = "mason" ] && perl -p -i -e "\ - s/%%%FREESIDE_DOCUMENT_ROOT%%%/${FREESIDE_DOCUMENT_ROOT}/g; + s/%%%FREESIDE_DOCUMENT_ROOT%%%/${FREESIDE_DOCUMENT_ROOT}/g; \ " ${MASON_HANDLER} [ "${TEMPLATE}" = "mason" -a ! -e ${MASONDATA} ] && mkdir ${MASONDATA} || true [ "${TEMPLATE}" = "mason" ] && chown -R freeside ${MASONDATA} || true -- cgit v1.2.1 From 06f0a601e40a06106f1d603edf3657c6753279ff Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 13 Mar 2004 01:27:41 +0000 Subject: really add the necessary backslashes this time, fix s/// delimteres --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index f6f7ae516..dc50433d2 100644 --- a/Makefile +++ b/Makefile @@ -121,9 +121,9 @@ install-docs: docs [ "${TEMPLATE}" = "asp" ] && chown -R freeside ${ASP_GLOBAL} || true [ "${TEMPLATE}" = "asp" ] && cp htetc/global.asa ${ASP_GLOBAL} || true [ "${TEMPLATE}" = "mason" ] && cp htetc/handler.pl ${MASON_HANDLER} || true - [ "${TEMPLATE}" = "mason" ] && + [ "${TEMPLATE}" = "mason" ] && \ perl -p -i -e "\ - s/%%%FREESIDE_DOCUMENT_ROOT%%%/${FREESIDE_DOCUMENT_ROOT}/g; \ + s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g; \ " ${MASON_HANDLER} [ "${TEMPLATE}" = "mason" -a ! -e ${MASONDATA} ] && mkdir ${MASONDATA} || true [ "${TEMPLATE}" = "mason" ] && chown -R freeside ${MASONDATA} || true -- cgit v1.2.1 From 6c5e54768bdf79070efd43963c1132fed7885eb1 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 15 Mar 2004 19:22:25 +0000 Subject: signup is now just a wrapper around self-service --- fs_signup/FS-SignupClient/MANIFEST | 1 - fs_signup/FS-SignupClient/Makefile.PL | 6 +-- fs_signup/FS-SignupClient/fs_signupd | 86 ----------------------------------- 3 files changed, 3 insertions(+), 90 deletions(-) delete mode 100755 fs_signup/FS-SignupClient/fs_signupd diff --git a/fs_signup/FS-SignupClient/MANIFEST b/fs_signup/FS-SignupClient/MANIFEST index b4a9900c8..365ae660b 100644 --- a/fs_signup/FS-SignupClient/MANIFEST +++ b/fs_signup/FS-SignupClient/MANIFEST @@ -4,5 +4,4 @@ MANIFEST.SKIP Makefile.PL SignupClient.pm test.pl -fs_signupd cgi/signup.cgi diff --git a/fs_signup/FS-SignupClient/Makefile.PL b/fs_signup/FS-SignupClient/Makefile.PL index 310200b57..9850c870d 100644 --- a/fs_signup/FS-SignupClient/Makefile.PL +++ b/fs_signup/FS-SignupClient/Makefile.PL @@ -4,9 +4,9 @@ use ExtUtils::MakeMaker; WriteMakefile( 'NAME' => 'FS::SignupClient', 'VERSION_FROM' => 'SignupClient.pm', # finds $VERSION - 'EXE_FILES' => [ 'fs_signupd' ], - 'INSTALLSCRIPT' => '/usr/local/sbin', - 'INSTALLSITEBIN' => '/usr/local/sbin', +# 'EXE_FILES' => [ 'fs_signupd' ], +# 'INSTALLSCRIPT' => '/usr/local/sbin', +# 'INSTALLSITEBIN' => '/usr/local/sbin', 'PERM_RWX' => '750', 'PREREQ_PM' => { 'Business::CreditCard' => 0, diff --git a/fs_signup/FS-SignupClient/fs_signupd b/fs_signup/FS-SignupClient/fs_signupd deleted file mode 100755 index 85bd68a2f..000000000 --- a/fs_signup/FS-SignupClient/fs_signupd +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/perl -Tw -# -# fs_signupd -# -# This is run REMOTELY over ssh by fs_signup_server. - -use strict; -use Socket; -use Storable qw(nstore_fd fd_retrieve); -use IO::Handle; - -use vars qw( $Debug ); - -$Debug = 1; - -my $fs_signupd_socket = "/usr/local/freeside/fs_signupd_socket"; -my $pid_file = "$fs_signupd_socket.pid"; - -$ENV{'PATH'} ='/usr/local/bin:/usr/bin:/usr/ucb:/bin'; -$ENV{'SHELL'} = '/bin/sh'; -$ENV{'IFS'} = " \t\n"; -$ENV{'CDPATH'} = ''; -$ENV{'ENV'} = ''; -$ENV{'BASH_ENV'} = ''; - -$|=1; - -warn "[fs_signupd] Reading init data...\n" if $Debug; -my $init_data = fd_retrieve(\*STDIN); - -warn "[fs_signupd] Creating $fs_signupd_socket\n" if $Debug; -my $uaddr = sockaddr_un($fs_signupd_socket); -my $proto = getprotobyname('tcp'); -socket(Server,PF_UNIX,SOCK_STREAM,0) or die "socket: $!"; -unlink($fs_signupd_socket); -bind(Server, $uaddr) or die "bind: $!"; -listen(Server,SOMAXCONN) or die "listen: $!"; - -if ( -e $pid_file ) { - open(PIDFILE,"<$pid_file"); - #chomp( my $old_pid = ); - my $old_pid = ; - close PIDFILE; - $old_pid =~ /^(\d+)$/; - kill 'TERM', $1; -} -open(PIDFILE,">$pid_file"); -print PIDFILE "$$\n"; -close PIDFILE; - -warn "[fs_signupd] Entering main loop...\n" if $Debug; -my $paddr; -for ( ; $paddr = accept(Client,Server); close Client) { - - chop( my $command = ); - - if ( $command eq "signup_info" ) { - - warn "[fs_signupd] sending signup info...\n" if $Debug; - nstore_fd($init_data, \*Client) or die "can't send init data: $!"; - Client->flush; - - } elsif ( $command eq "new_customer" ) { - - #inefficient... - - warn "[fs_signupd] reading customer signup...\n" if $Debug; - my $signup_data = fd_retrieve(\*Client); - - warn "[fs_signupd] sending customer data to remote server...\n" if $Debug; - nstore_fd($signup_data, \*STDOUT) or die "can't send signup data: $!"; - STDOUT->flush; - - warn "[fs_signupd] reading error from remote server...\n" if $Debug; - my $error = ; - - warn "[fs_signupd] sending error to local client...\n" if $Debug; - print Client $error; - Client->flush; - - } else { - die "unexpected command from client: $command"; - } - -} - -- cgit v1.2.1 From 4060bc129c8b4e2ea1b699b48fb8bf69608c4b0c Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 16 Mar 2004 00:34:43 +0000 Subject: dont want to error out here --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index dc50433d2..ba1f5cd17 100644 --- a/Makefile +++ b/Makefile @@ -124,7 +124,7 @@ install-docs: docs [ "${TEMPLATE}" = "mason" ] && \ perl -p -i -e "\ s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g; \ - " ${MASON_HANDLER} + " ${MASON_HANDLER} || true [ "${TEMPLATE}" = "mason" -a ! -e ${MASONDATA} ] && mkdir ${MASONDATA} || true [ "${TEMPLATE}" = "mason" ] && chown -R freeside ${MASONDATA} || true -- cgit v1.2.1 From 8ce96f4accb45f2577d38de81b9f96c0031a2f8a Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 16 Mar 2004 04:36:16 +0000 Subject: recognize DBD::mysqlPP --- FS/FS/cust_svc.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/FS/FS/cust_svc.pm b/FS/FS/cust_svc.pm index 0d8a12114..b97539681 100644 --- a/FS/FS/cust_svc.pm +++ b/FS/FS/cust_svc.pm @@ -380,7 +380,7 @@ sub seconds_since_sqlradacct { #select a unix time conversion function based on database type my $str2time; - if ( $dbh->{Driver}->{Name} eq 'mysql' ) { + if ( $dbh->{Driver}->{Name} =~ /^mysql(PP)?$/ ) { $str2time = 'UNIX_TIMESTAMP('; } elsif ( $dbh->{Driver}->{Name} eq 'Pg' ) { $str2time = 'EXTRACT( EPOCH FROM '; @@ -498,7 +498,7 @@ sub attribute_since_sqlradacct { #select a unix time conversion function based on database type my $str2time; - if ( $dbh->{Driver}->{Name} eq 'mysql' ) { + if ( $dbh->{Driver}->{Name} =~ /^mysql(PP)?$/ ) { $str2time = 'UNIX_TIMESTAMP('; } elsif ( $dbh->{Driver}->{Name} eq 'Pg' ) { $str2time = 'EXTRACT( EPOCH FROM '; @@ -561,7 +561,7 @@ sub get_session_history { #select a unix time conversion function based on database type my $str2time; - if ( $dbh->{Driver}->{Name} eq 'mysql' ) { + if ( $dbh->{Driver}->{Name} =~ /^mysql(PP)?$/ ) { $str2time = 'UNIX_TIMESTAMP('; } elsif ( $dbh->{Driver}->{Name} eq 'Pg' ) { $str2time = 'EXTRACT( EPOCH FROM '; -- cgit v1.2.1 From ae11d16db998c044e523030cc026b2d0c0bc981b Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 16 Mar 2004 06:43:15 +0000 Subject: initial (hopefully rather unobtrusive) patch --- rt/FREESIDE_MODIFIED | 1 + rt/sbin/rt-setup-database | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 rt/FREESIDE_MODIFIED diff --git a/rt/FREESIDE_MODIFIED b/rt/FREESIDE_MODIFIED new file mode 100644 index 000000000..e41fc2f68 --- /dev/null +++ b/rt/FREESIDE_MODIFIED @@ -0,0 +1 @@ +sbin/rt-setup-database diff --git a/rt/sbin/rt-setup-database b/rt/sbin/rt-setup-database index 58f882f6e..83e08270a 100644 --- a/rt/sbin/rt-setup-database +++ b/rt/sbin/rt-setup-database @@ -110,6 +110,9 @@ elsif ( $args{'action'} eq 'drop' ) { } drop_db(); } +elsif ( $args{'action'} eq 'insert_initial' ) { + insert_initial_data(); +} elsif ( $args{'action'} eq 'insert' ) { insert_data( $args{'datafile'} ); } -- cgit v1.2.1 From d5097ef7712573de5faf223de8c9ec0a43ffcff0 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 16 Mar 2004 06:45:22 +0000 Subject: initial RT targets --- Makefile | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Makefile b/Makefile index ba1f5cd17..20b70af67 100644 --- a/Makefile +++ b/Makefile @@ -70,6 +70,7 @@ help: @echo " perl-modules install-perl-modules" @echo " install deploy" @echo " create-database" + @echo " configure-rt create-rt" @echo " clean" aspdocs: htmlman httemplate/* httemplate/*/* httemplate/*/*/* httemplate/*/*/*/* httemplate/*/*/*/*/* @@ -183,6 +184,24 @@ create-config: install-perl-modules mkdir "${FREESIDE_CONF}/export.${DATASOURCE}" chown freeside "${FREESIDE_CONF}/export.${DATASOURCE}" +configure-rt: + cd rt; \ + ./configure --htmldir=${FREESIDE_DOCUMENT_ROOT}/rt \ + --masonstatedir=${MASONDATA} \ + --with-db-type=Pg \ + --with-db-database=freeside \ + --with-db-rt-user=${DB_USER} \ + --with-db-rt-pass=${DB_PASSWORD} \ + --with-web-user=freeside \ + --with-web-group=www + +create-rt: configure-rt + cd rt; make install + rt/sbin/rt-initialize-database --action schema + rt/sbin/rt-initialize-database --action insert_initial + rt/sbin/rt-initialize-database --action insert --datafile rt/etc/initialdata + + clean: rm -rf aspdocs masondocs cd FS; \ -- cgit v1.2.1 From 746f4a81b7cc2073a06675a08e930d9f2d76cbb0 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 16 Mar 2004 06:58:01 +0000 Subject: config.layout needs to be generated --- rt/FREESIDE_MODIFIED | 2 + rt/config.layout | 104 ----------------------------------------- rt/config.layout.in | 127 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 129 insertions(+), 104 deletions(-) delete mode 100644 rt/config.layout create mode 100644 rt/config.layout.in diff --git a/rt/FREESIDE_MODIFIED b/rt/FREESIDE_MODIFIED index e41fc2f68..cab7db3cf 100644 --- a/rt/FREESIDE_MODIFIED +++ b/rt/FREESIDE_MODIFIED @@ -1 +1,3 @@ sbin/rt-setup-database +config.layout +config.layout.in diff --git a/rt/config.layout b/rt/config.layout deleted file mode 100644 index 23a7775d6..000000000 --- a/rt/config.layout +++ /dev/null @@ -1,104 +0,0 @@ -## -## config.layout -- Pre-defined Installation Path Layouts -## -## Hints: -## - layouts can be loaded with configure's --enable-layout=ID option -## - when no --enable-layout option is given, the default layout is `RT' -## - a trailing plus character (`+') on paths is replaced with a -## `/' suffix where is currently hardcoded to 'rt3'. -## (This may become a configurable parameter at some point.) -## -## The following variables must _all_ be set: -## prefix exec_prefix bindir sbindir sysconfdir mandir libdir -## datadir htmldir localstatedir logfiledir masonstatedir -## sessionstatedir customdir customhtmldir customlexdir -## (This can be seen in m4/rt_layout.m4.) -## - -# Default RT3 path layout. - - prefix: /opt/rt3 - exec_prefix: ${prefix} - bindir: ${exec_prefix}/bin - sbindir: ${exec_prefix}/sbin - sysconfdir: ${prefix}/etc - mandir: ${prefix}/man - libdir: ${prefix}/lib - datadir: ${prefix}/share - htmldir: ${datadir}/html - manualdir: ${datadir}/doc - localstatedir: ${prefix}/var - logfiledir: ${localstatedir}/log - masonstatedir: ${localstatedir}/mason_data - sessionstatedir: ${localstatedir}/session_data - customdir: ${prefix}/local - custometcdir: ${customdir}/etc - customhtmldir: ${customdir}/html - customlexdir: ${customdir}/po - customlibdir: ${customdir}/lib - - - prefix: `pwd` - exec_prefix: ${prefix} - bindir: ${exec_prefix}/bin - sbindir: ${exec_prefix}/sbin - sysconfdir: ${prefix}/etc - mandir: ${prefix}/man - libdir: ${prefix}/lib - datadir: ${prefix}/share - htmldir: ${prefix}/html - manualdir: ${datadir}/doc - localstatedir: ${prefix}/var - logfiledir: ${localstatedir}/log - masonstatedir: ${localstatedir}/mason_data - sessionstatedir: ${localstatedir}/session_data - customdir: ${prefix}/local - custometcdir: ${customdir}/etc - customhtmldir: ${customdir}/html - customlexdir: ${customdir}/po - customlibdir: ${customdir}/lib - - - - prefix: /usr/local - exec_prefix: ${prefix} - bindir: ${exec_prefix}/bin - sbindir: ${exec_prefix}/sbin - sysconfdir: ${prefix}/etc+ - mandir: ${prefix}/man - libdir: ${prefix}/lib+ - datadir: ${prefix}/share+ - htmldir: ${datadir}/html - manualdir: ${prefix}/share/doc+ - logfiledir: /var/log - localstatedir: /var/run+ - masonstatedir: ${localstatedir}/mason_data - sessionstatedir: ${localstatedir}/session_data - customdir: ${prefix}/share+ - custometcdir: ${customdir}/local/etc - customhtmldir: ${customdir}/local/html - customlexdir: ${customdir}/local/po - customlibdir: ${customdir}/local/lib - - - - prefix: C:/Program Files/Request Tracker - exec_prefix: ${prefix} - bindir: ${exec_prefix}/bin - sbindir: ${exec_prefix}/sbin - sysconfdir: ${prefix}/etc - mandir: ${prefix}/man - libdir: ${prefix}/lib - datadir: ${prefix} - htmldir: ${datadir}/html - manualdir: ${datadir}/doc - localstatedir: ${prefix}/var - logfiledir: ${localstatedir}/log - masonstatedir: ${localstatedir}/mason_data - sessionstatedir: ${localstatedir}/session_data - customdir: ${prefix}/local - custometcdir: ${customdir}/etc - customhtmldir: ${customdir}/html - customlexdir: ${customdir}/po - customlibdir: ${customdir}/lib - diff --git a/rt/config.layout.in b/rt/config.layout.in new file mode 100644 index 000000000..63ed61be9 --- /dev/null +++ b/rt/config.layout.in @@ -0,0 +1,127 @@ +## +## config.layout -- Pre-defined Installation Path Layouts +## +## Hints: +## - layouts can be loaded with configure's --enable-layout=ID option +## - when no --enable-layout option is given, the default layout is `RT' +## - a trailing plus character (`+') on paths is replaced with a +## `/' suffix where is currently hardcoded to 'rt3'. +## (This may become a configurable parameter at some point.) +## +## The following variables must _all_ be set: +## prefix exec_prefix bindir sbindir sysconfdir mandir libdir +## datadir htmldir localstatedir logfiledir masonstatedir +## sessionstatedir customdir customhtmldir customlexdir +## (This can be seen in m4/rt_layout.m4.) +## + +# Default RT3 path layout. + + prefix: /opt/rt3 + exec_prefix: ${prefix} + bindir: ${exec_prefix}/bin + sbindir: ${exec_prefix}/sbin + sysconfdir: ${prefix}/etc + mandir: ${prefix}/man + libdir: ${prefix}/lib + datadir: ${prefix}/share + htmldir: ${datadir}/html + manualdir: ${datadir}/doc + localstatedir: ${prefix}/var + logfiledir: ${localstatedir}/log + masonstatedir: ${localstatedir}/mason_data + sessionstatedir: ${localstatedir}/session_data + customdir: ${prefix}/local + custometcdir: ${customdir}/etc + customhtmldir: ${customdir}/html + customlexdir: ${customdir}/po + customlibdir: ${customdir}/lib + + + prefix: `pwd` + exec_prefix: ${prefix} + bindir: ${exec_prefix}/bin + sbindir: ${exec_prefix}/sbin + sysconfdir: ${prefix}/etc + mandir: ${prefix}/man + libdir: ${prefix}/lib + datadir: ${prefix}/share + htmldir: ${prefix}/html + manualdir: ${datadir}/doc + localstatedir: ${prefix}/var + logfiledir: ${localstatedir}/log + masonstatedir: ${localstatedir}/mason_data + sessionstatedir: ${localstatedir}/session_data + customdir: ${prefix}/local + custometcdir: ${customdir}/etc + customhtmldir: ${customdir}/html + customlexdir: ${customdir}/po + customlibdir: ${customdir}/lib + + + + prefix: /usr/local + exec_prefix: ${prefix} + bindir: ${exec_prefix}/bin + sbindir: ${exec_prefix}/sbin + sysconfdir: ${prefix}/etc+ + mandir: ${prefix}/man + libdir: ${prefix}/lib+ + datadir: ${prefix}/share+ + htmldir: ${datadir}/html + manualdir: ${prefix}/share/doc+ + logfiledir: /var/log + localstatedir: /var/run+ + masonstatedir: ${localstatedir}/mason_data + sessionstatedir: ${localstatedir}/session_data + customdir: ${prefix}/share+ + custometcdir: ${customdir}/local/etc + customhtmldir: ${customdir}/local/html + customlexdir: ${customdir}/local/po + customlibdir: ${customdir}/local/lib + + + + prefix: C:/Program Files/Request Tracker + exec_prefix: ${prefix} + bindir: ${exec_prefix}/bin + sbindir: ${exec_prefix}/sbin + sysconfdir: ${prefix}/etc + mandir: ${prefix}/man + libdir: ${prefix}/lib + datadir: ${prefix} + htmldir: ${datadir}/html + manualdir: ${datadir}/doc + localstatedir: ${prefix}/var + logfiledir: ${localstatedir}/log + masonstatedir: ${localstatedir}/mason_data + sessionstatedir: ${localstatedir}/session_data + customdir: ${prefix}/local + custometcdir: ${customdir}/etc + customhtmldir: ${customdir}/html + customlexdir: ${customdir}/po + customlibdir: ${customdir}/lib + + + + prefix: /opt/rt3 + exec_prefix: ${prefix} + bindir: ${exec_prefix}/bin + sbindir: ${exec_prefix}/sbin + sysconfdir: ${prefix}/etc + mandir: ${prefix}/man + libdir: ${prefix}/lib + datadir: ${prefix}/share + htmldir: %%%FREESIDE_DOCUMENT_ROOT%%%/rt + manualdir: ${datadir}/doc + localstatedir: ${prefix}/var + logfiledir: ${localstatedir}/log + masonstatedir: ${localstatedir}/mason_data + sessionstatedir: ${localstatedir}/session_data + customdir: ${prefix}/local + custometcdir: ${customdir}/etc + customhtmldir: ${customdir}/html + customlexdir: ${customdir}/po + customlibdir: ${customdir}/lib + + -- cgit v1.2.1 From 503094650e95d616b467c51e96ec70be0bd79e57 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 16 Mar 2004 06:59:51 +0000 Subject: autogenerate rt/config.layout file --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 20b70af67..dd55046a7 100644 --- a/Makefile +++ b/Makefile @@ -186,7 +186,11 @@ create-config: install-perl-modules configure-rt: cd rt; \ - ./configure --htmldir=${FREESIDE_DOCUMENT_ROOT}/rt \ + cp config.layout.in config.layout; \ + perl -p -i -e \" + s/%%%FREESIDE_DOCUMENT_ROOT%%%/${FREESIDE_DOCUMENT_ROOT}/g;\ + " config.layout + ./configure --with-layout=Freeside\ --masonstatedir=${MASONDATA} \ --with-db-type=Pg \ --with-db-database=freeside \ -- cgit v1.2.1 From 6b54ceeb39da7915624bbcac63fb16e463916709 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 16 Mar 2004 07:00:57 +0000 Subject: transposition --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index dd55046a7..42f1b85f1 100644 --- a/Makefile +++ b/Makefile @@ -187,7 +187,7 @@ create-config: install-perl-modules configure-rt: cd rt; \ cp config.layout.in config.layout; \ - perl -p -i -e \" + perl -p -i -e "\ s/%%%FREESIDE_DOCUMENT_ROOT%%%/${FREESIDE_DOCUMENT_ROOT}/g;\ " config.layout ./configure --with-layout=Freeside\ -- cgit v1.2.1 From 0bfec9596615f85454378af865677e49f0a4f68d Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 16 Mar 2004 07:03:07 +0000 Subject: use a proper delimter --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 42f1b85f1..7f06cb7ef 100644 --- a/Makefile +++ b/Makefile @@ -188,7 +188,7 @@ configure-rt: cd rt; \ cp config.layout.in config.layout; \ perl -p -i -e "\ - s/%%%FREESIDE_DOCUMENT_ROOT%%%/${FREESIDE_DOCUMENT_ROOT}/g;\ + s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g;\ " config.layout ./configure --with-layout=Freeside\ --masonstatedir=${MASONDATA} \ -- cgit v1.2.1 From 8be4f17f8bda91fdf61a5f22314a04ba23e8f489 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 16 Mar 2004 07:04:08 +0000 Subject: and finally, run the ./configure --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 7f06cb7ef..bce1d6145 100644 --- a/Makefile +++ b/Makefile @@ -189,7 +189,7 @@ configure-rt: cp config.layout.in config.layout; \ perl -p -i -e "\ s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g;\ - " config.layout + " config.layout; \ ./configure --with-layout=Freeside\ --masonstatedir=${MASONDATA} \ --with-db-type=Pg \ -- cgit v1.2.1 From 5491c4474430dde5f3087894dc0e90b8d46fc552 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 16 Mar 2004 07:06:17 +0000 Subject: masonstatedir can't be configured form ./configure either, must use layout --- Makefile | 2 +- rt/config.layout.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index bce1d6145..d71046f41 100644 --- a/Makefile +++ b/Makefile @@ -189,9 +189,9 @@ configure-rt: cp config.layout.in config.layout; \ perl -p -i -e "\ s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g;\ + s'%%%MASONDATA%%%'${MASONDATA}'g;\ " config.layout; \ ./configure --with-layout=Freeside\ - --masonstatedir=${MASONDATA} \ --with-db-type=Pg \ --with-db-database=freeside \ --with-db-rt-user=${DB_USER} \ diff --git a/rt/config.layout.in b/rt/config.layout.in index 63ed61be9..a08f48948 100644 --- a/rt/config.layout.in +++ b/rt/config.layout.in @@ -116,7 +116,7 @@ manualdir: ${datadir}/doc localstatedir: ${prefix}/var logfiledir: ${localstatedir}/log - masonstatedir: ${localstatedir}/mason_data + masonstatedir: %%%MASONDATA%%% sessionstatedir: ${localstatedir}/session_data customdir: ${prefix}/local custometcdir: ${customdir}/etc -- cgit v1.2.1 From d57a7d6d2e1bedca8a0df351a3054baa6e57ea4a Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 16 Mar 2004 20:41:31 +0000 Subject: rt-setup-database, not rt-initialize-database --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index d71046f41..e5ef70d6c 100644 --- a/Makefile +++ b/Makefile @@ -201,9 +201,9 @@ configure-rt: create-rt: configure-rt cd rt; make install - rt/sbin/rt-initialize-database --action schema - rt/sbin/rt-initialize-database --action insert_initial - rt/sbin/rt-initialize-database --action insert --datafile rt/etc/initialdata + rt/sbin/rt-setup-database --action schema + rt/sbin/rt-setup-database --action insert_initial + rt/sbin/rt-setup-database --action insert --datafile rt/etc/initialdata clean: -- cgit v1.2.1 From 72a65ceaa28155e8c1c3c1328dd76587b35e089a Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 17 Mar 2004 21:47:56 +0000 Subject: proper self-service login supporting plaintext, crypt and MD5 passwords --- FS/FS/ClientAPI/MyAccount.pm | 23 +++++++++-------------- FS/FS/ClientAPI/passwd.pm | 20 ++++++++------------ FS/FS/svc_acct.pm | 31 +++++++++++++++++++++++++++++++ httemplate/docs/install.html | 1 + httemplate/docs/upgrade-1.4.2.html | 1 + 5 files changed, 50 insertions(+), 26 deletions(-) diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm index 445f0ece8..a865a22d5 100644 --- a/FS/FS/ClientAPI/MyAccount.pm +++ b/FS/FS/ClientAPI/MyAccount.pm @@ -44,24 +44,19 @@ my $cache = new Cache::SharedMemoryCache( { 'namespace' => 'FS::ClientAPI::MyAccount', } ); -#false laziness w/FS::ClientAPI::passwd::passwd (needs to handle encrypted pw) +#false laziness w/FS::ClientAPI::passwd::passwd sub login { my $p = shift; my $svc_domain = qsearchs('svc_domain', { 'domain' => $p->{'domain'} } ) - or return { error => "Domain not found" }; - - my $svc_acct = - ( length($p->{'password'}) < 13 - && qsearchs( 'svc_acct', { 'username' => $p->{'username'}, - 'domsvc' => $svc_domain->svcnum, - '_password' => $p->{'password'} } ) - ) - || qsearchs( 'svc_acct', { 'username' => $p->{'username'}, - 'domsvc' => $svc_domain->svcnum, - '_password' => $p->{'password'} } ); - - unless ( $svc_acct ) { return { error => 'Incorrect password.' } } + or return { error => 'Domain '. $p->{'domain'}. ' not found' }; + + my $svc_acct = qsearchs( 'svc_acct', { 'username' => $p->{'username'}, + 'domsvc' => $svc_domain->svcnum, } + ); + return { error => 'User not found.' } unless $svc_acct; + return { error => 'Incorrect password.' } + unless $svc_acct->check_password($p->{'password'}); my $session = { 'svcnum' => $svc_acct->svcnum, diff --git a/FS/FS/ClientAPI/passwd.pm b/FS/FS/ClientAPI/passwd.pm index 016ebff79..96110ef3a 100644 --- a/FS/FS/ClientAPI/passwd.pm +++ b/FS/FS/ClientAPI/passwd.pm @@ -24,18 +24,14 @@ sub passwd { my $new_gecos = $packet->{'new_gecos'}; my $new_shell = $packet->{'new_shell'}; -#false laziness w/FS::ClientAPI::MyAccount::login (needs to handle encrypted pw) - my $svc_acct = - ( length($old_password) < 13 - && qsearchs( 'svc_acct', { 'username' => $packet->{'username'}, - 'domsvc' => $svc_domain->svcnum, - '_password' => $old_password } ) - ) - || qsearchs( 'svc_acct', { 'username' => $packet->{'username'}, - 'domsvc' => $svc_domain->svcnum, - '_password' => $old_password } ); - - unless ( $svc_acct ) { return { error => 'Incorrect password.' } } + #false laziness w/FS::ClientAPI::MyAccount::login + + my $svc_acct = qsearchs( 'svc_acct', { 'username' => $packet->{'username'}, + 'domsvc' => $svc_domain->svcnum, } + ); + return { error => 'User not found.' } unless $svc_acct; + return { error => 'Incorrect password.' } + unless $svc_acct->check_password($old_password); my %hash = $svc_acct->hash; my $new_svc_acct = new FS::svc_acct ( \%hash ); diff --git a/FS/FS/svc_acct.pm b/FS/FS/svc_acct.pm index d84240f36..991cedd21 100644 --- a/FS/FS/svc_acct.pm +++ b/FS/FS/svc_acct.pm @@ -14,6 +14,7 @@ use vars qw( @ISA $DEBUG $me $conf @saltset @pw_set ); use Carp; use Fcntl qw(:flock); +use Crypt::PasswdMD5; use FS::UID qw( datasrc ); use FS::Conf; use FS::Record qw( qsearch qsearchs fields dbh dbdef ); @@ -1116,6 +1117,36 @@ sub clone_kludge_unsuspend { new FS::svc_acct \%hash; } +=item check_password + +Checks the supplied password against the (possibly encrypted) password in the +database. Returns true for a sucessful authentication, false for no match. + +Currently supported encryptions are: classic DES crypt() and MD5 + +=cut + +sub check_password { + my($self, $check_password) = @_; + #eventually should check a "password-encoding" field + if ( length($self->_password) < 13 ) { #plaintext + $check_password eq $self->_password; + } elsif ( length($self->_password) == 13 ) { #traditional DES crypt + crypt($check_password, $self->_password) eq $self->_password; + } elsif ( $self->_password =~ /^\$1\$/ ) { #MD5 crypt + unix_md5_crypt($check_password, $self->_password) eq $self->_password; + } elsif ( $self->_password =~ /^\$2a?\$/ ) { #Blowfish + warn "Can't check password: Blowfish encryption not yet supported, svcnum". + $self->svcnum. "\n"; + 0; + } else { + warn "Can't check password: Unrecognized encryption for svcnum ". + $self->svcnum. "\n"; + 0; + } + +} + =back =head1 SUBROUTINES diff --git a/httemplate/docs/install.html b/httemplate/docs/install.html index ed306f2d3..0217c9085 100644 --- a/httemplate/docs/install.html +++ b/httemplate/docs/install.html @@ -56,6 +56,7 @@ Before installing, you need:
  • NetAddr-IP
  • Chart +
  • Crypt::PasswdMD5
  • Apache::DBI (optional but recommended for better webinterface performance) diff --git a/httemplate/docs/upgrade-1.4.2.html b/httemplate/docs/upgrade-1.4.2.html index 3c9ac9c6d..b8c5fcf7e 100644 --- a/httemplate/docs/upgrade-1.4.2.html +++ b/httemplate/docs/upgrade-1.4.2.html @@ -13,6 +13,7 @@
  • Install DBD::Pg 1.32.
  • Install Cache::Cache.
  • Install Net::SSH 0.08. +
  • Install Crypt::PasswdMD5
  • CGI.pm minimum version 2.47 is required. You will probably need to install a current CGI.pm from CPAN if you are using Perl 5.005 or earlier.
  • If using Apache::ASP, add PerlSetVar RequestBinaryRead Off to your Apache configuration and make sure you are using Apache::ASP minimum version 2.55.
  • Run make aspdocs or make masondocs. -- cgit v1.2.1 From 44a98d88974faf787ba4f4264ee9532c86e19f1f Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 17 Mar 2004 22:45:15 +0000 Subject: add -d and -r options --- bin/shadow.reimport | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/bin/shadow.reimport b/bin/shadow.reimport index 2c0ad1fea..4cb68a583 100755 --- a/bin/shadow.reimport +++ b/bin/shadow.reimport @@ -1,8 +1,12 @@ -#!/usr/bin/perl -Tw -# $Id: shadow.reimport,v 1.1 2004-02-03 00:19:45 ivan Exp $ +#!/usr/bin/perl -w +# +# -d: dry-run: make no changes +# -r: replace: overwrite existing passwords (otherwise only "*" passwords will +# be changed) use strict; use vars qw(%part_svc); +use Getopt::Std; use Term::Query qw(query); use Net::SCP qw(iscp); use FS::UID qw(adminsuidsetup datasrc); @@ -10,6 +14,9 @@ use FS::Record qw(qsearch qsearchs); use FS::svc_acct; use FS::part_svc; +use vars qw($opt_d $opt_r); +getopts("dr"); + my $user = shift or die &usage; adminsuidsetup $user; @@ -29,14 +36,15 @@ die "No services with svcdb svc_acct!\n" unless %part_svc; print "\n\n", &menu_svc, "\n", <svc, sort keys %part_svc ). "\n"; @@ -73,18 +81,25 @@ while () { next unless @svc_acct; if ( scalar(@svc_acct) > 1 ) { - warn "more than one $username found!\n"; + die "more than one $username found!\n"; next; } my $svc_acct = shift @svc_acct; + next unless $svc_acct->_password eq '*' || $opt_r; + next if $svc_acct->_password eq $password; + next if $svc_acct->_password =~ /^\*SUSPENDED\*/; my $new_svc_acct = new FS::svc_acct( { $svc_acct->hash } ); $new_svc_acct->_password($password); - #my $error = $new_svc_acct->replace($svc_acct); - #die "$username: $error" if $error; + #warn "$username: ". $svc_acct->_password. " -> $password\n"; + warn "changing password for $username\n"; + unless ( $opt_d ) { + my $error = $new_svc_acct->replace($svc_acct); + die "$username: $error" if $error; + } $updated++; @@ -93,6 +108,6 @@ while () { warn "$updated of $line passwords changed\n"; sub usage { - die "Usage:\n\n shadow.reimport user\n"; + die "Usage:\n\n shadow.reimport [ -d ] [ -r ] user\n"; } -- cgit v1.2.1 From 389dad7142dd7bf9c4b12d42958ebec50e4ae400 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 17 Mar 2004 22:49:26 +0000 Subject: re-enable prompting --- bin/shadow.reimport | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/bin/shadow.reimport b/bin/shadow.reimport index 4cb68a583..846cb89c5 100755 --- a/bin/shadow.reimport +++ b/bin/shadow.reimport @@ -36,15 +36,14 @@ die "No services with svcdb svc_acct!\n" unless %part_svc; print "\n\n", &menu_svc, "\n", <svc, sort keys %part_svc ). "\n"; -- cgit v1.2.1 From c2962f704aa7711489f2dd2fc8be3396095aa166 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 17 Mar 2004 22:53:07 +0000 Subject: allow multiple svcparts --- bin/shadow.reimport | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/bin/shadow.reimport b/bin/shadow.reimport index 846cb89c5..4d112d753 100755 --- a/bin/shadow.reimport +++ b/bin/shadow.reimport @@ -34,9 +34,10 @@ $FS::svc_Common::noexport_hack = 1; die "No services with svcdb svc_acct!\n" unless %part_svc; print "\n\n", &menu_svc, "\n", <) { chop; my($username,$password)=split(/:/); - my @svc_acct = grep { $_->cust_svc->svcpart == $shell_svcpart } - qsearch('svc_acct', { 'username' => $username } ); +# my @svc_acct = grep { $_->cust_svc->svcpart == $shell_svcpart } +# qsearch('svc_acct', { 'username' => $username } ); + my @svc_acct = grep { + my $svcpart = $_->cust_svc->svcpart; + grep { $_ == $svcpart } @shell_svcpart; + } qsearch('svc_acct', { 'username' => $username } ); next unless @svc_acct; -- cgit v1.2.1 From 9ceb48a8f852ba25cc569d2da87c092cf33b3a28 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 17 Mar 2004 22:55:51 +0000 Subject: fix multiple svcparts --- bin/shadow.reimport | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/shadow.reimport b/bin/shadow.reimport index 4d112d753..a02582d96 100755 --- a/bin/shadow.reimport +++ b/bin/shadow.reimport @@ -36,7 +36,7 @@ die "No services with svcdb svc_acct!\n" unless %part_svc; print "\n\n", &menu_svc, "\n", < Date: Wed, 17 Mar 2004 23:08:48 +0000 Subject: skip root user and anyone with *LK* or NP accounts --- bin/shadow.reimport | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bin/shadow.reimport b/bin/shadow.reimport index a02582d96..2fc90d7f2 100755 --- a/bin/shadow.reimport +++ b/bin/shadow.reimport @@ -93,6 +93,10 @@ while () { next unless $svc_acct->_password eq '*' || $opt_r; + next if $svc_acct->username eq 'root'; + + next if $password eq 'NP' || $password eq '*LK*'; + next if $svc_acct->_password eq $password; next if $svc_acct->_password =~ /^\*SUSPENDED\*/; -- cgit v1.2.1 From 32ce27b2183644a901bc79f16278ae750537fbdd Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 17 Mar 2004 23:16:21 +0000 Subject: fixup password checking to understand old-style *SUSPENDED* accounts and not to allow access for * ! !! passwords --- FS/FS/svc_acct.pm | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/FS/FS/svc_acct.pm b/FS/FS/svc_acct.pm index 991cedd21..4ea52520c 100644 --- a/FS/FS/svc_acct.pm +++ b/FS/FS/svc_acct.pm @@ -1128,14 +1128,21 @@ Currently supported encryptions are: classic DES crypt() and MD5 sub check_password { my($self, $check_password) = @_; + + #remove old-style SUSPENDED kludge, they should be allowed to login to + #self-service and pay up + ( my $password = $self->_password ) =~ s/^\*SUSPENDED\* //; + #eventually should check a "password-encoding" field - if ( length($self->_password) < 13 ) { #plaintext - $check_password eq $self->_password; - } elsif ( length($self->_password) == 13 ) { #traditional DES crypt - crypt($check_password, $self->_password) eq $self->_password; - } elsif ( $self->_password =~ /^\$1\$/ ) { #MD5 crypt - unix_md5_crypt($check_password, $self->_password) eq $self->_password; - } elsif ( $self->_password =~ /^\$2a?\$/ ) { #Blowfish + if ( $password =~ /^(\*|!!?)$/ ) { #no self-service login + return 0; + } elsif ( length($password) < 13 ) { #plaintext + $check_password eq $password; + } elsif ( length($password) == 13 ) { #traditional DES crypt + crypt($check_password, $password) eq $password; + } elsif ( $password =~ /^\$1\$/ ) { #MD5 crypt + unix_md5_crypt($check_password, $password) eq $password; + } elsif ( $password =~ /^\$2a?\$/ ) { #Blowfish warn "Can't check password: Blowfish encryption not yet supported, svcnum". $self->svcnum. "\n"; 0; -- cgit v1.2.1 From cccf2f33d38b693c2742b5806e32d892d31b4374 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 18 Mar 2004 01:46:40 +0000 Subject: require Storable minimum 2.09 --- FS/bin/freeside-selfservice-server | 2 +- fs_selfservice/FS-SelfService/SelfService.pm | 3 ++- fs_selfservice/FS-SelfService/freeside-selfservice-clientd | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/FS/bin/freeside-selfservice-server b/FS/bin/freeside-selfservice-server index 03c7135b2..864c2d46e 100644 --- a/FS/bin/freeside-selfservice-server +++ b/FS/bin/freeside-selfservice-server @@ -15,7 +15,7 @@ use POSIX qw(:sys_wait_h setsid); use IO::Handle; use IO::Select; use IO::File; -use Storable qw(nstore_fd fd_retrieve); +use Storable 2.09 qw(nstore_fd fd_retrieve); use Net::SSH qw(sshopen2); use FS::UID qw(adminsuidsetup forksuidsetup); use FS::ClientAPI; diff --git a/fs_selfservice/FS-SelfService/SelfService.pm b/fs_selfservice/FS-SelfService/SelfService.pm index 715f935f3..7cbf5ecad 100644 --- a/fs_selfservice/FS-SelfService/SelfService.pm +++ b/fs_selfservice/FS-SelfService/SelfService.pm @@ -7,7 +7,7 @@ use Socket; use FileHandle; #use IO::Handle; use IO::Select; -use Storable qw(nstore_fd fd_retrieve); +use Storable 2.09 qw(nstore_fd fd_retrieve); $VERSION = '0.03'; @@ -31,6 +31,7 @@ $socket .= '.'.$tag if defined $tag && length($tag); 'list_pkgs' => 'MyAccount/list_pkgs', 'order_pkg' => 'MyAccount/order_pkg', 'cancel_pkg' => 'MyAccount/cancel_pkg', + 'charge' => 'MyAccount/charge', 'signup_info' => 'Signup/signup_info', 'new_customer' => 'Signup/new_customer', ); diff --git a/fs_selfservice/FS-SelfService/freeside-selfservice-clientd b/fs_selfservice/FS-SelfService/freeside-selfservice-clientd index 925bce6d2..ce9e14d35 100644 --- a/fs_selfservice/FS-SelfService/freeside-selfservice-clientd +++ b/fs_selfservice/FS-SelfService/freeside-selfservice-clientd @@ -9,7 +9,7 @@ use subs qw(spawn logmsg lock_write unlock_write); use Fcntl qw(:flock); use POSIX qw(:sys_wait_h); use Socket; -use Storable qw(nstore_fd fd_retrieve); +use Storable 2.09 qw(nstore_fd fd_retrieve); use IO::Handle qw(_IONBF); use IO::Select; use IO::File; @@ -233,6 +233,7 @@ sub spawn { sub _logmsg { chomp( my $msg = shift ); my $log = new IO::File ">>$log_file"; + die "can't open $log_file: $!" unless defined($log); flock($log, LOCK_EX); seek($log, 0, 2); print $log "[client] [". scalar(localtime). "] [$$] $msg\n"; -- cgit v1.2.1 From bb70dc0af47c15b8041ebc85b6eff234a26baa14 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 18 Mar 2004 20:58:11 +0000 Subject: don't re-crypt encrypted passwords --- FS/FS/part_export/shellcommands.pm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/FS/FS/part_export/shellcommands.pm b/FS/FS/part_export/shellcommands.pm index db2e7aaf9..a4eb0a052 100644 --- a/FS/FS/part_export/shellcommands.pm +++ b/FS/FS/part_export/shellcommands.pm @@ -59,9 +59,15 @@ sub _export_command { $finger = shell_quote $finger; $quoted_password = shell_quote $_password; $domain = $svc_acct->domain; - $crypt_password = ''; #surpress "used only once" warnings - $crypt_password = crypt( $svc_acct->_password, + + #eventually should check a "password-encoding" field + if ( length($svc_acct->_password) == 13 + || $svc_acct->_password =~ /^\$(1|2a?)\$/ ) { + $crypt_password = $svc_acct->_password; + } else { + $crypt_password = crypt( $svc_acct->_password, $saltset[int(rand(64))].$saltset[int(rand(64))] ); + } $self->shellcommands_queue( $svc_acct->svcnum, user => $self->option('user')||'root', -- cgit v1.2.1 From 3b7030c2c7464c2a1b409cdc22fad4a593d4f231 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 18 Mar 2004 22:00:25 +0000 Subject: add -b option --- bin/shadow.reimport | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bin/shadow.reimport b/bin/shadow.reimport index 2fc90d7f2..7957011eb 100755 --- a/bin/shadow.reimport +++ b/bin/shadow.reimport @@ -3,6 +3,8 @@ # -d: dry-run: make no changes # -r: replace: overwrite existing passwords (otherwise only "*" passwords will # be changed) +# -b: blowfish replace: overwrite existing passwords only if they are +# blowfish-encrypted use strict; use vars qw(%part_svc); @@ -14,8 +16,8 @@ use FS::Record qw(qsearch qsearchs); use FS::svc_acct; use FS::part_svc; -use vars qw($opt_d $opt_r); -getopts("dr"); +use vars qw($opt_d $opt_r $opt_b); +getopts("drb"); my $user = shift or die &usage; adminsuidsetup $user; @@ -91,7 +93,9 @@ while () { my $svc_acct = shift @svc_acct; - next unless $svc_acct->_password eq '*' || $opt_r; + next unless $svc_acct->_password eq '*' + || $opt_r + || ( $opt_b && $svc_acct->_password =~ /^\$2a?\$/ ); next if $svc_acct->username eq 'root'; -- cgit v1.2.1 From b0011320cc2c33233ee694c61903667d2d3d8e5b Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 18 Mar 2004 22:32:02 +0000 Subject: don't re-encrypt password on replace also --- FS/FS/part_export/shellcommands.pm | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/FS/FS/part_export/shellcommands.pm b/FS/FS/part_export/shellcommands.pm index a4eb0a052..1eb0d8367 100644 --- a/FS/FS/part_export/shellcommands.pm +++ b/FS/FS/part_export/shellcommands.pm @@ -65,8 +65,10 @@ sub _export_command { || $svc_acct->_password =~ /^\$(1|2a?)\$/ ) { $crypt_password = $svc_acct->_password; } else { - $crypt_password = crypt( $svc_acct->_password, - $saltset[int(rand(64))].$saltset[int(rand(64))] ); + $crypt_password = crypt( + $svc_acct->_password, + $saltset[int(rand(64))].$saltset[int(rand(64))] + ); } $self->shellcommands_queue( $svc_acct->svcnum, @@ -92,9 +94,17 @@ sub _export_replace { $new_quoted_password = shell_quote $new__password; #new, better? $old_domain = $old->domain; $new_domain = $new->domain; - $new_crypt_password = ''; #surpress "used only once" warnings - $new_crypt_password = crypt( $new->_password, - $saltset[int(rand(64))].$saltset[int(rand(64))]); + + #eventuall should check a "password-encoding" field + if ( length($new->_password) == 13 + || $new->_password =~ /^\$(1|2a?)\$/ ) { + $new_crypt_password = $new->_password; + } else { + $new_crypt_password = + crypt( $new->_password, $saltset[int(rand(64))].$saltset[int(rand(64))] + ); + } + if ( $self->option('usermod_pwonly') ) { my $error = ''; if ( $old_username ne $new_username ) { -- cgit v1.2.1 From 880355353822e9d4a2fbd9100cad7c74179c1a59 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 18 Mar 2004 22:35:32 +0000 Subject: quote already-crypted passwords to prevent variable substitution --- FS/FS/part_export/shellcommands.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FS/FS/part_export/shellcommands.pm b/FS/FS/part_export/shellcommands.pm index 1eb0d8367..9fad36dad 100644 --- a/FS/FS/part_export/shellcommands.pm +++ b/FS/FS/part_export/shellcommands.pm @@ -63,7 +63,7 @@ sub _export_command { #eventually should check a "password-encoding" field if ( length($svc_acct->_password) == 13 || $svc_acct->_password =~ /^\$(1|2a?)\$/ ) { - $crypt_password = $svc_acct->_password; + $crypt_password = shell_quote $svc_acct->_password; } else { $crypt_password = crypt( $svc_acct->_password, @@ -98,7 +98,7 @@ sub _export_replace { #eventuall should check a "password-encoding" field if ( length($new->_password) == 13 || $new->_password =~ /^\$(1|2a?)\$/ ) { - $new_crypt_password = $new->_password; + $new_crypt_password = shell_quote $new->_password; } else { $new_crypt_password = crypt( $new->_password, $saltset[int(rand(64))].$saltset[int(rand(64))] -- cgit v1.2.1 From f1ddcafa4ef383b57357e7e4100b974044f14803 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 19 Mar 2004 12:36:01 +0000 Subject: use FS::svc_domain explicitly --- FS/FS/ClientAPI/passwd.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FS/FS/ClientAPI/passwd.pm b/FS/FS/ClientAPI/passwd.pm index 96110ef3a..cb839ecef 100644 --- a/FS/FS/ClientAPI/passwd.pm +++ b/FS/FS/ClientAPI/passwd.pm @@ -3,7 +3,7 @@ package FS::ClientAPI::passwd; use strict; use FS::Record qw(qsearchs); use FS::svc_acct; -#use FS::svc_domain; +use FS::svc_domain; use FS::ClientAPI; #hmm FS::ClientAPI->register_handlers( -- cgit v1.2.1 From 5a5242465520ef7a64a715496c31a3c17c95cc57 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 22 Mar 2004 02:59:39 +0000 Subject: much easier to understand listing of credits/payments that get split up, closes: Bug#773, 762 --- httemplate/view/cust_main.cgi | 451 +++++++++++++++++++++++------------------- 1 file changed, 250 insertions(+), 201 deletions(-) diff --git a/httemplate/view/cust_main.cgi b/httemplate/view/cust_main.cgi index c41d2d894..229362e6c 100755 --- a/httemplate/view/cust_main.cgi +++ b/httemplate/view/cust_main.cgi @@ -15,14 +15,16 @@ print header("Customer View", menubar( 'Main Menu' => popurl(2) )); -print < + -END + +<% die "No customer specified (bad URL)!" unless $cgi->keywords; my($query) = $cgi->keywords; # needs parens with my, ->keywords returns array @@ -33,14 +35,16 @@ die "Customer not found!" unless $cust_main; print qq!Edit this customer!; -print < + -END + +<% print qq! | !. 'Cancel this customer' @@ -348,7 +352,8 @@ if ( $conf->config('payby-default') ne 'HIDE' ) { } -print < + -END + +<% print qq!
    Packages !, # qq!
    Click on package number to view/edit package.!, @@ -536,13 +542,12 @@ foreach my $pkg (sort pkgsort_pkgnum_cancel @$packages) { } } } -print '' +print ''; } #end display packages +%> - -print < function cust_pay_areyousure(href) { if (confirm("Are you sure you want to delete this payment?") @@ -565,169 +570,205 @@ function cust_credit_areyousure(href) { window.location.href = href; } -END -if ( $conf->config('payby-default') ne 'HIDE' ) { - - #formatting - print qq!

    Payment History!. - qq! ( !. - qq!!. - qq!Post payment | !. - qq!!. - qq!Post credit )!; +<% if ( $conf->config('payby-default') ne 'HIDE' ) { %> +

    Payment History + (Post payment + | Post credit) + + <% #get payment history - # - # major problem: this whole thing is way too sloppy. - # minor problem: the description lines need better formatting. - - my @history = (); #needed for mod_perl :) - - my %target = (); - - my @bills = qsearch('cust_bill',{'custnum'=>$custnum}); - foreach my $bill (@bills) { - my($bref)=$bill->hashref; - my $bpre = ( $bill->owed > 0 ) - ? ' Open ' - : ''; - my $bpost = ( $bill->owed > 0 ) ? '' : ''; - push @history, - $bref->{_date} . qq!\t${bpre}Invoice #! . $bref->{invnum} . - qq! (Balance \$! . $bill->owed . qq!)$bpost\t! . - $bref->{charged} . qq!\t\t\t!; - - my(@cust_bill_pay)=qsearch('cust_bill_pay',{'invnum'=> $bref->{invnum} } ); - # my(@payments)=qsearch('cust_pay',{'invnum'=> $bref->{invnum} } ); - # my($payment); - foreach my $cust_bill_pay (@cust_bill_pay) { - my $payment = $cust_bill_pay->cust_pay; - my($date,$invnum,$payby,$payinfo,$paid)=($payment->_date, - $cust_bill_pay->invnum, - $payment->payby, - $payment->payinfo, - $cust_bill_pay->amount, - ); - $payinfo = 'x'x(length($payinfo)-4). substr($payinfo,(length($payinfo)-4)) - if $payby eq 'CARD'; - my $target = "$payby$payinfo"; - $payby =~ s/^BILL$/Check #/ if $payinfo; - $payby =~ s/^(CARD|COMP)$/$1 /; - my $delete = $payment->closed !~ /^Y/i && $conf->exists('deletepayments') - ? qq! (delete)! - : ''; - my $unapply = - $payment->closed !~ /^Y/i && $conf->exists('unapplypayments') - ? qq! (unapply)! - : ''; - push @history, - "$date\tPayment, Invoice #$invnum ($payby$payinfo)$delete$unapply\t\t$paid\t\t\t$target"; + my @history = (); + + #invoices + foreach my $cust_bill ($cust_main->cust_bill) { + my $pre = ( $cust_bill->owed > 0 ) + ? 'Open ' + : ''; + my $post = ( $cust_bill->owed > 0 ) ? '' : ''; + my $invnum = $cust_bill->invnum; + push @history, { + 'date' => $cust_bill->_date, + 'desc' => qq!!. $pre. + "Invoice #$invnum (Balance \$". $cust_bill->owed. ')'. + $post. '', + 'charge' => $cust_bill->charged, + }; + } + + #payments (some false laziness w/credits) + foreach my $cust_pay ($cust_main->cust_pay) { + + my $payby = $cust_pay->payby; + my $payinfo = $cust_pay->payinfo; + my @cust_bill_pay = $cust_pay->cust_bill_pay; + + $payinfo = 'x'x(length($payinfo)-4). substr($payinfo,(length($payinfo)-4)) + if $payby eq 'CARD'; + my $target = "$payby$payinfo"; + $payby =~ s/^BILL$/Check #/ if $payinfo; + $payby =~ s/^BILL$//; + $payby =~ s/^(CARD|COMP)$/$1 /; + my $info = $payby ? " ($payby$payinfo)" : ''; + + my( $pre, $post, $desc, $apply, $ext ) = ( '', '', '', '', '' ); + if ( scalar(@cust_bill_pay) == 0 ) { + #completely unapplied + $pre = 'Unapplied '; + $post = ''; + $apply = qq! (apply)'; + } elsif ( scalar(@cust_bill_pay) == 1 && $cust_pay->unapplied == 0 ) { + #applied to one invoice + $desc = ' applied to Invoice #'. $cust_bill_pay[0]->invnum; + } else { + #complicated + $desc = '
    '; + foreach my $cust_bill_pay (@cust_bill_pay) { + $desc .= '  '. + '$'. $cust_bill_pay->amount. + ' applied to Invoice #'. $cust_bill_pay->invnum. + '
    '; + #' on '. time2str("%D", $cust_bill_pay->_date). + + } + if ( $cust_pay->unapplied > 0 ) { + $desc .= '  '. + '$'. + $cust_pay->unapplied. ' unapplied'. + qq! (apply)'. + '
    '; + } } - - my(@cust_credit_bill)= - qsearch('cust_credit_bill', { 'invnum'=> $bref->{invnum} } ); - foreach my $cust_credit_bill (@cust_credit_bill) { - my $cust_credit = $cust_credit_bill->cust_credit; - my($date, $invnum, $crednum, $amount, $reason, $app_date ) = ( - $cust_credit->_date, - $cust_credit_bill->invnum, - $cust_credit_bill->crednum, - $cust_credit_bill->amount, - $cust_credit->reason, - time2str("%D", $cust_credit_bill->_date), - ); - my $delete = - $cust_credit->closed !~ /^Y/i && $conf->exists('deletecredits') - ? qq! (delete)! - : ''; - my $unapply = - $cust_credit->closed !~ /^Y/i && $conf->exists('unapplycredits') - ? qq! (unapply)! - : ''; - push @history, - "$date\tCredit #$crednum: $reason
    ". - "(applied to invoice #$invnum on $app_date)$delete$unapply\t\t\t$amount\t"; + + my $delete = ''; + if ( $cust_pay->closed !~ /^Y/i && $conf->exists('deletepayments') ) { + $delete = qq! (delete)!; } - } - - my @credits = grep { scalar(my @array = $_->cust_credit_refund) } - qsearch('cust_credit',{'custnum'=>$custnum}); - foreach my $credit (@credits) { - my($cref)=$credit->hashref; - my(@cust_credit_refund)= - qsearch('cust_credit_refund', { 'crednum'=> $cref->{crednum} } ); - foreach my $cust_credit_refund (@cust_credit_refund) { - my $cust_refund = $cust_credit_refund->cust_credit; - my($date, $crednum, $amount, $reason, $app_date ) = ( - $credit->_date, - $credit->crednum, - $cust_credit_refund->amount, - $credit->reason, - time2str("%D", $cust_credit_refund->_date), - ); - push @history, - "$date\tCredit #$crednum: $reason
    ". - "(applied to refund on $app_date)\t\t\t$amount\t"; + + my $unapply = ''; + if ( $cust_pay->closed !~ /^Y/i + && $conf->exists('unapplypayments') + && scalar(@cust_bill_pay) ) { + $unapply = qq! (unapply)!; } + + push @history, { + 'date' => $cust_pay->_date, + 'desc' => $pre. "Payment$post$info$desc". + "$apply$delete$unapply", + 'payment' => $cust_pay->paid, + 'target' => $target, + }; } - - @credits = grep { $_->credited > 0 } - qsearch('cust_credit',{'custnum'=>$custnum}); - foreach my $credit (@credits) { - my($cref)=$credit->hashref; - my $delete = - $credit->closed !~ /^Y/i && $conf->exists('deletecredits') - ? qq! (delete)! - : ''; - push @history, - $cref->{_date} . "\t" . - qq!!. - 'Unapplied credit #' . - $cref->{crednum} . ": ". - $cref->{reason} . "$delete\t\t\t" . $credit->credited . "\t"; - } - - my(@refunds)=qsearch('cust_refund',{'custnum'=> $custnum } ); - foreach my $refund (@refunds) { - my($rref)=$refund->hashref; - my($refundnum) = ( - $refund->refundnum, - ); - - push @history, - $rref->{_date} . "\tRefund #$refundnum, (" . - $rref->{payby} . " " . $rref->{payinfo} . ") by " . - $rref->{otaker} . " - ". $rref->{reason} . "\t\t\t\t" . - $rref->{refund}; + + #credits (some false laziness w/payments) + foreach my $cust_credit ($cust_main->cust_credit) { + + my @cust_credit_bill = $cust_credit->cust_credit_bill; + my @cust_credit_refund = $cust_credit->cust_credit_refund; + + my( $pre, $post, $desc, $apply, $ext ) = ( '', '', '', '', '' ); + if ( scalar(@cust_credit_bill) == 0 + && scalar(@cust_credit_refund) == 0 ) { + #completely unapplied + $pre = 'Unapplied '; + $post = ''; + $apply = qq! (apply)'; + } elsif ( scalar(@cust_credit_bill) == 1 + && scalar(@cust_credit_refund) == 0 + && $cust_credit->credited == 0 ) { + #applied to one invoice + $desc = ' applied to Invoice #'. $cust_credit_bill[0]->invnum; + } elsif ( scalar(@cust_credit_bill) == 0 + && scalar(@cust_credit_refund) == 1 + && $cust_credit->credited == 0 ) { + #applied to one refund + $desc = ' refunded on '. time2str("%D", $cust_credit_refund[0]->_date); + } else { + #complicated + $desc = '
    '; + foreach my $app ( sort { $a->_date <=> $b->_date } + ( @cust_credit_bill, @cust_credit_refund ) ) { + if ( $app->isa('FS::cust_credit_bill') ) { + $desc .= '  '. + '$'. $app->amount. + ' applied to Invoice #'. $app->invnum. + '
    '; + #' on '. time2str("%D", $app->_date). + } elsif ( $app->isa('FS::cust_credit_refund') ) { + $desc .= '  '. + '$'. $app->amount. + ' refunded on'. time2str("%D", $app->_date). + '
    '; + } else { + die "$app is not a FS::cust_credit_bill or a FS::cust_credit_refund"; + } + } + if ( $cust_credit->credited > 0 ) { + $desc .= ' - $'. + $cust_credit->unapplied. ' unapplied'. + qq! (apply'. + '
    '; + } + } +# + my $delete = ''; + if ( $cust_credit->closed !~ /^Y/i && $conf->exists('deletecredits') ) { + $delete = qq! (delete)!; + } + + my $unapply = ''; + if ( $cust_credit->closed !~ /^Y/i + && $conf->exists('unapplycredits') + && scalar(@cust_credit_bill) ) { + $unapply = qq! (unapply)!; + } + + push @history, { + 'date' => $cust_credit->_date, + 'desc' => $pre. "Credit$post by ". $cust_credit->otaker. + ' ('. $cust_credit->reason. ')'. + "$desc$apply$delete$unapply", + 'credit' => $cust_credit->amount, + }; + } - - my @unapplied_payments = - grep { $_->unapplied > 0 } qsearch('cust_pay', { 'custnum' => $custnum } ); - foreach my $payment (@unapplied_payments) { - my $payby = $payment->payby; - my $payinfo = $payment->payinfo; - #false laziness w/above + + #refunds + foreach my $cust_refund ($cust_main->cust_refund) { + + my $payby = $cust_refund->payby; + my $payinfo = $cust_refund->payinfo; + $payinfo = 'x'x(length($payinfo)-4). substr($payinfo,(length($payinfo)-4)) if $payby eq 'CARD'; - my $target = "$payby$payinfo"; $payby =~ s/^BILL$/Check #/ if $payinfo; $payby =~ s/^(CARD|COMP)$/$1 /; - my $delete = $payment->closed !~ /^Y/i && $conf->exists('deletepayments') - ? qq! (delete)! - : ''; - push @history, - $payment->_date. "\t". - 'Unapplied payment #' . - $payment->paynum . " ($payby$payinfo) ". - '('. - "apply)$delete". - "\t\t" . $payment->unapplied . "\t\t\t$target"; + + push @history, { + 'date' => $cust_refund->_date, + 'desc' => "Refund ($payby$payinfo) by ". $cust_refund->otaker, + 'refund' => $cust_refund->refund, + }; + } - #formatting - print &table(), < + + <%= table() %> Date Description @@ -737,59 +778,67 @@ if ( $conf->config('payby-default') ne 'HIDE' ) { Refund Balance -END - + + <% #display payment history - + + my %target; my $balance = 0; - foreach my $item (sort keyfield_numerically @history) { - my($date,$desc,$charge,$payment,$credit,$refund,$target)=split(/\t/,$item); - $charge ||= 0; - $payment ||= 0; - $credit ||= 0; - $refund ||= 0; - $balance += $charge - $payment; - $balance -= $credit - $refund; + foreach my $item ( sort { $a->{'date'} <=> $b->{'date'} } @history ) { + + my $charge = exists($item->{'charge'}) + ? sprintf('$%.2f', $item->{'charge'}) + : ''; + my $payment = exists($item->{'payment'}) + ? sprintf('- $%.2f', $item->{'payment'}) + : ''; + my $credit = exists($item->{'credit'}) + ? sprintf('- $%.2f', $item->{'credit'}) + : ''; + my $refund = exists($item->{'refund'}) + ? sprintf('$%.2f', $item->{'refund'}) + : ''; + + my $target = exists($item->{'target'}) ? $item->{'target'} : ''; + + $balance += $item->{'charge'} if exists $item->{'charge'}; + $balance -= $item->{'payment'} if exists $item->{'payment'}; + $balance -= $item->{'credit'} if exists $item->{'credit'}; + $balance += $item->{'refund'} if exists $item->{'refund'}; $balance = sprintf("%.2f", $balance); $balance =~ s/^\-0\.00$/0.00/; #yay ieee fp - $target = '' unless defined $target; + + %> - print ""; - print qq!! unless $target && $target{$target}++; - print time2str("%D",$date); - print '' if $target && $target{$target} == 1; - print "", - "$desc", - "", - ( $charge ? "\$".sprintf("%.2f",$charge) : '' ), - "", - "", - ( $payment ? "- \$".sprintf("%.2f",$payment) : '' ), - "", - "", - ( $credit ? "- \$".sprintf("%.2f",$credit) : '' ), - "", - "", - ( $refund ? "\$".sprintf("%.2f",$refund) : '' ), - "", - "\$" . $balance, - "", - "\n"; - } + + + <% unless ( !$target || $target{$target}++ ) { %> + + <% } %> + <%= time2str("%D",$item->{'date'}) %> + <% if ( $target && $target{$target} == 1 ) { %> + + <% } %> + + + <%= $item->{'desc'} %> + <%= $charge %> + <%= $payment %> + <%= $credit %> + <%= $refund %> + $<%= $balance %> + + + <% } %> - print ""; - -} + -print ''; - -#subroutiens -sub keyfield_numerically { (split(/\t/,$a))[0] <=> (split(/\t/,$b))[0]; } +<% } %> -%> + <% - +#subroutines sub get_packages { my $cust_main = shift or return undef; -- cgit v1.2.1 From 351b0af13ba6c449151c1bec2303294051c073d1 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 22 Mar 2004 10:16:43 +0000 Subject: yay! remove package view entirely (closes: Bug#569) --- httemplate/misc/expire_pkg.cgi | 64 +++++++++++++++++++++++++--------- httemplate/misc/process/expire_pkg.cgi | 25 +++++++++++++ httemplate/view/cust_main.cgi | 40 ++++++++++++--------- 3 files changed, 96 insertions(+), 33 deletions(-) create mode 100755 httemplate/misc/process/expire_pkg.cgi diff --git a/httemplate/misc/expire_pkg.cgi b/httemplate/misc/expire_pkg.cgi index 9e4ce8b62..b59674a69 100755 --- a/httemplate/misc/expire_pkg.cgi +++ b/httemplate/misc/expire_pkg.cgi @@ -1,25 +1,55 @@ + <% -#untaint date & pkgnum - -my $date; -if ( $cgi->param('date') ) { - str2time($cgi->param('date')) =~ /^(\d+)$/ or die "Illegal date"; - $date=$1; -} else { - $date=''; -} - -$cgi->param('pkgnum') =~ /^(\d+)$/ or die "Illegal pkgnum"; +my($query) = $cgi->keywords; +$query =~ /^(\d+)$/; my $pkgnum = $1; +#get package record my $cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); -my %hash = $cust_pkg->hash; -$hash{expire}=$date; -my $new = new FS::cust_pkg ( \%hash ); -my $error = $new->replace($cust_pkg); -&eidiot($error) if $error; +die "Unknown pkgnum $pkgnum" unless $cust_pkg; +my $part_pkg = $cust_pkg->part_pkg; + +my $custnum = $cust_pkg->getfield('custnum'); -print $cgi->redirect(popurl(2). "view/cust_main.cgi?".$cust_pkg->getfield('custnum')); +my $date = $cust_pkg->expire ? time2str('%D', $cust_pkg->expire) : ''; %> + +<%= header('Expire package', menubar( + "View this customer (#$custnum)" => "${p}view/cust_main.cgi?$custnum", + 'Main Menu' => popurl(2) +)) %> + + + + + + +<%= $pkgnum %>: <%= $part_pkg->pkg. ' - '. $part_pkg->comment %> + +
    + + + + + + +
    Cancel package on + +
    m/d/y +
    + + + + +
    + + diff --git a/httemplate/misc/process/expire_pkg.cgi b/httemplate/misc/process/expire_pkg.cgi new file mode 100755 index 000000000..dc35592ce --- /dev/null +++ b/httemplate/misc/process/expire_pkg.cgi @@ -0,0 +1,25 @@ +<% + +#untaint date & pkgnum + +my $date; +if ( $cgi->param('date') ) { + str2time($cgi->param('date')) =~ /^(\d+)$/ or die "Illegal date"; + $date=$1; +} else { + $date=''; +} + +$cgi->param('pkgnum') =~ /^(\d+)$/ or die "Illegal pkgnum"; +my $pkgnum = $1; + +my $cust_pkg = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); +my %hash = $cust_pkg->hash; +$hash{expire}=$date; +my $new = new FS::cust_pkg ( \%hash ); +my $error = $new->replace($cust_pkg); +&eidiot($error) if $error; + +print $cgi->redirect(popurl(3). "view/cust_main.cgi?".$cust_pkg->getfield('custnum')); + +%> diff --git a/httemplate/view/cust_main.cgi b/httemplate/view/cust_main.cgi index 229362e6c..8d8af63d6 100755 --- a/httemplate/view/cust_main.cgi +++ b/httemplate/view/cust_main.cgi @@ -20,7 +20,6 @@ print header("Customer View", menubar( @@ -382,7 +381,7 @@ if ( @$packages ) { %> - + @@ -402,9 +401,9 @@ foreach my $pkg (sort pkgsort_pkgnum_cancel @$packages) { %> - \n! if ($cnt > 0); - print qq! \n\n!; + print qq! \n\n!; } } } @@ -946,13 +945,21 @@ sub svc_label_link { } sub svc_provision_link { - my ($pkg, $svcpart) = (shift,shift) or return ''; + my ($pkg, $svcpart, $conf) = @_; ( my $svc_nbsp = $svcpart->{svc} ) =~ s/\s+/ /g; - return qq!! . - "Provision $svc_nbsp (". - ($svcpart->{quantity} - $svcpart->{count}). - ')'; + my $pkgnum_svcpart = "pkgnum$pkg->{pkgnum}-svcpart$svcpart->{svcpart}"; + my $num_left = $svcpart->{quantity} - $svcpart->{count}; + + my $link = qq!!. + "Provision $svc_nbsp ($num_left)"; + if ( $conf->exists('legacy_link') ) { + $link .= '
    '. + qq!!. + "Link to legacy $svc_nbsp ($num_left)"; + } + $link; } sub svc_unprovision_link { @@ -983,10 +990,10 @@ sub pkg_datestr { $strip; } -sub pkg_details_link { - my $pkg = shift or return ''; - return qq!Details!; -} +#sub pkg_details_link { +# my $pkg = shift or return ''; +# return qq!Details!; +#} sub pkg_change_link { my $pkg = shift or return ''; @@ -1005,7 +1012,8 @@ sub pkg_unsuspend_link { sub pkg_cancel_link { my $pkg = shift or return ''; - return qq!Cancel!; + qq!Cancel now | !. + qq!Cancel later!; } sub pkg_dates_link { -- cgit v1.2.1
    PackagePackage Status Services
    CLASS="pkgnum"><%=$pkg->{pkgnum}%> > - <%=$pkg->{pkg}%> - <%=$pkg->{comment}%> ( <%=pkg_details_link($pkg)%> )
    + <%=$pkg->{pkgnum}%>: + <%=$pkg->{pkg}%> - <%=$pkg->{comment}%>
    <% unless ($pkg->{cancel}) { %> ( <%=pkg_change_link($pkg)%> ) ( <%=pkg_dates_link($pkg)%> | <%=pkg_customize_link($pkg,$custnum)%> ) @@ -538,7 +537,7 @@ foreach my $pkg (sort pkgsort_pkgnum_cancel @$packages) { } if ($svcpart->{count} < $svcpart->{quantity}) { print qq!
    !.svc_provision_link($pkg,$svcpart).qq!
    !.svc_provision_link($pkg, $svcpart, $conf).qq!