webbuild: add backend-side files

This commit is contained in:
Silvan Calarco 2012-09-02 13:18:52 +02:00
parent b9803712a2
commit b36a8a552e
5 changed files with 1339 additions and 0 deletions

View File

@ -12,6 +12,7 @@ sbindir = ${exec_prefix}/sbin
bindir = ${exec_prefix}/bin bindir = ${exec_prefix}/bin
datadir = ${prefix}/share datadir = ${prefix}/share
initrddir = ${sysconfdir}/rc.d/init.d initrddir = ${sysconfdir}/rc.d/init.d
libexecdir = ${prefix}/libexec
mandir = ${prefix}/usr/share/man mandir = ${prefix}/usr/share/man
sysconfigdir= ${sysconfdir}/sysconfig sysconfigdir= ${sysconfdir}/sysconfig
configdir = ${sysconfdir}/autodist configdir = ${sysconfdir}/autodist
@ -57,6 +58,7 @@ install-dirs:
@$(INSTALL_DIR) $(DESTDIR)$(pck_logdir)/send/{ok,failed} @$(INSTALL_DIR) $(DESTDIR)$(pck_logdir)/send/{ok,failed}
@$(INSTALL_DIR) $(DESTDIR)$(pck_datadir)/RPM/{SPECS,SRPMS,BUILD,SOURCES,RPMS/{noarch,i586,ppc,x86_64,arm}} @$(INSTALL_DIR) $(DESTDIR)$(pck_datadir)/RPM/{SPECS,SRPMS,BUILD,SOURCES,RPMS/{noarch,i586,ppc,x86_64,arm}}
@$(INSTALL_DIR) $(DESTDIR)$(piddir) @$(INSTALL_DIR) $(DESTDIR)$(piddir)
@$(INSTALL_DIR) $(DESTDIR)$(libexecdir)
install-programs: install-programs:
@$(INSTALL_SCRIPT) autodist $(DESTDIR)$(bindir)/autodist @$(INSTALL_SCRIPT) autodist $(DESTDIR)$(bindir)/autodist
@ -66,6 +68,9 @@ install-programs:
@$(INSTALL_SCRIPT) autoport-fix-environment $(DESTDIR)$(bindir)/autoport-fix-environment @$(INSTALL_SCRIPT) autoport-fix-environment $(DESTDIR)$(bindir)/autoport-fix-environment
@$(INSTALL_SCRIPT) etc/autodist/scripts/* $(DESTDIR)$(configdir)/scripts/ @$(INSTALL_SCRIPT) etc/autodist/scripts/* $(DESTDIR)$(configdir)/scripts/
@$(INSTALL_SCRIPT) autodist-cgi $(DESTDIR)$(cgidir)/autodist @$(INSTALL_SCRIPT) autodist-cgi $(DESTDIR)$(cgidir)/autodist
@$(INSTALL_SCRIPT) webbuild/webbuild-cgi $(DESTDIR)$(cgidir)/webbuild
@$(INSTALL_SCRIPT) webbuild/webbuild-sudo $(DESTDIR)$(libexecdir)/webbuild-sudo
@$(INSTALL_SCRIPT) webbuild/webbuild-checkpassword $(DESTDIR)$(libexecdir)/webbuild-checkpassword
install-data: install-data:
@$(INSTALL_DATA) etc/autodist/config $(DESTDIR)$(configdir)/config @$(INSTALL_DATA) etc/autodist/config $(DESTDIR)$(configdir)/config
@ -84,6 +89,7 @@ install-data:
@$(INSTALL_DATA) etc/autodist/blacklist $(DESTDIR)$(configdir)/blacklist @$(INSTALL_DATA) etc/autodist/blacklist $(DESTDIR)$(configdir)/blacklist
@$(INSTALL_DATA) etc/autodist/distdb.d/* $(DESTDIR)$(configdir)/distdb.d/ @$(INSTALL_DATA) etc/autodist/distdb.d/* $(DESTDIR)$(configdir)/distdb.d/
@$(INSTALL_DATA) etc/sudoers.d/autoport $(DESTDIR)$(sysconfdir)/sudoers.d/autoport @$(INSTALL_DATA) etc/sudoers.d/autoport $(DESTDIR)$(sysconfdir)/sudoers.d/autoport
@$(INSTALL_DATA) webbuild/webbuild-sudoers $(DESTDIR)$(sysconfdir)/sudoers.d/webbuild
@$(INSTALL_SCRIPT) etc/sysconfig/autoport $(DESTDIR)$(sysconfdir)/sysconfig/autoport @$(INSTALL_SCRIPT) etc/sysconfig/autoport $(DESTDIR)$(sysconfdir)/sysconfig/autoport
@$(INSTALL_SCRIPT) etc/cron.hourly/65-autoport $(DESTDIR)$(sysconfdir)/cron.hourly/ @$(INSTALL_SCRIPT) etc/cron.hourly/65-autoport $(DESTDIR)$(sysconfdir)/cron.hourly/
@$(INSTALL_SCRIPT) etc/cron.daily/40-autodist-cleanold $(DESTDIR)$(sysconfdir)/cron.daily/ @$(INSTALL_SCRIPT) etc/cron.daily/40-autodist-cleanold $(DESTDIR)$(sysconfdir)/cron.daily/

995
webbuild/webbuild-cgi Executable file
View File

@ -0,0 +1,995 @@
#!/bin/bash
#
# webbuild cgi script
# Copyright (c) 2012 by Silvan Calarco <silvan.calarco@mambasoft.it>
#
. /etc/sysconfig/autoport
SUDO_WRAPPER="sudo /usr/libexec/webbuild-sudo"
STATEDIR=/var/autodist/webbuild
LOG=/var/autodist/webbuild/access_log
DEFAULT_ENVIRONMENT=0
[ "`uname -m`" = "x86_64" ] && HOST_IS_X86_64=1
#This code for getting code from post data is from http://oinkzwurgl.org/bash_cgi and
#was written by Phillippe Kehi <phkehi@gmx.net> and flipflip industries
# (internal) routine to store POST data
function cgi_get_POST_vars()
{
# check content type
# FIXME: not sure if we could handle uploads with this..
[ "${CONTENT_TYPE}" != "application/x-www-form-urlencoded" ] && \
echo "Warning: you should probably use MIME type "\
"application/x-www-form-urlencoded!" 1>&2
# save POST variables (only first time this is called)
[ -z "$QUERY_STRING_POST" \
-a "$REQUEST_METHOD" = "POST" -a ! -z "$CONTENT_LENGTH" ] &&
read -n $CONTENT_LENGTH QUERY_STRING_POST
return
}
# (internal) routine to decode urlencoded strings
function cgi_decodevar()
{
[ $# -ne 1 ] && return
local v t h
# replace all + with whitespace and append %%
t="${1//+/ }%%"
while [ ${#t} -gt 0 -a "${t}" != "%" ]; do
v="${v}${t%%\%*}" # digest up to the first %
t="${t#*%}" # remove digested part
# decode if there is anything to decode and if not at end of string
if [ ${#t} -gt 0 -a "${t}" != "%" ]; then
h=${t:0:2} # save first two chars
t="${t:2}" # remove these
if [ "${h}" = "22" ]; then
v="${v}\\\""
elif [ "${h}" = "0A" ]; then
v="${v}\\\n"
elif [ "${h}" = "24" ]; then
v="${v}\\\$"
elif [ "${h}" = "60" ]; then
v="${v}\\\`"
else
v="${v}"`echo -e \\\\x${h}` # convert hex to special char
fi
fi
done
# return decoded string
echo "${v}"
return
}
# routine to get variables from http requests
# usage: cgi_getvars method varname1 [.. varnameN]
# method is either GET or POST or BOTH
# the magic varible name ALL gets everything
function cgi_getvars()
{
[ $# -lt 2 ] && return
local q p k v s
# get query
case $1 in
GET)
[ ! -z "${QUERY_STRING}" ] && q="${QUERY_STRING}&"
;;
POST)
cgi_get_POST_vars
[ ! -z "${QUERY_STRING_POST}" ] && q="${QUERY_STRING_POST}&"
;;
BOTH)
[ ! -z "${QUERY_STRING}" ] && q="${QUERY_STRING}&"
cgi_get_POST_vars
[ ! -z "${QUERY_STRING_POST}" ] && q="${q}${QUERY_STRING_POST}&"
;;
esac
shift
s=" $* "
# parse the query data
while [ ! -z "$q" ]; do
p=`echo $q | sed "s|&.*||"`
q=`echo $q | sed "s|[^&]*&||"`
k="${p%%=*}" # get the key (variable name) from it
v="${p#*=}" # get the value from it
# decode and evaluate var if requested
if [ "$k" != "SPECTEXT" ]; then
v=`cgi_decodevar "$v"`
fi
eval "$k=\"$v\""
done
return
}
# register all GET and POST variables
cgi_getvars BOTH ALL
#cgi_getvars POST
if [ "$REQUEST" != "refresh" ]; then
# echo "`date` - $QUERY_STRING_POST" >> $LOG
echo "`date` - USER=$USER&REQUEST=$REQUEST&ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&MAINTAINERMODE=$MAINTAINERMODE" >> $LOG
fi
[ "$HOST" ] || HOST=0
[ "$AS_HOST" ] || AS_HOST=0
[ "$AS_HOST" -a "$HOST" != "0" ] && HOST_ADD="&HOST=$HOST"
if [ "$AS_HOST" = "0" ]; then
echo -e "Content-type: text/xml\nPragma: no-cache\n"
echo -n "<webbuild>"
else
echo -e "Content-type: text/html; charset=UTF-8\n"
fi
# SECURITY
USER_ENABLED=
USER=${USER/.*\/}
if [ "$SECRET" -a "$USER" ]; then
if [ -r "$STATEDIR/users/$USER" ]; then
. $STATEDIR/users/$USER
fi
if [ "$USER_ENABLED" ]; then
USER_ENABLED=
if [ "$SECRET" = "$USER_SECRET" ]; then
USER_ENABLED=1
elif [ ! "$SECRET" ]; then
USER_ENABLED=
elif [ "$USER_SECRET" ]; then
echo -n "<environments> </environments>"
echo -n "<speccreate> </speccreate>"
echo -n "<specedit> </specedit>"
echo -n "<repositories> </repositories>"
echo -n "<packages> </packages>"
echo -n "<editcontrols> </editcontrols>"
echo -n "<editor> </editor>"
echo -n "<output>Unauthorized! If this happened after you changed your password in openmamba website please ask the maintainer to be re-enabled to use this service. Thank you."
echo -n "</output>"
echo -n "<operationpanel> </operationpanel>"
echo -n "</webbuild>"
exit
elif [ "$REQUEST" = "password" ]; then
/usr/libexec/webbuild-checkpassword "$PASSWORD" "$SECRET" 2>/dev/null
if [ $? -eq 0 ]; then
tmpfile=`mktemp`
cat $STATEDIR/users/$USER > $tmpfile
echo "USER_SECRET='$SECRET'" >> $tmpfile
USER_ENABLED=1
$SUDO_WRAPPER local "" "mv $tmpfile $STATEDIR/users/$USER"
else
USER_ENABLED=
fi
else
# no "$USER_SECRET" set; require password
echo -n "<output><![CDATA[Please enter your password: <input type=password id=password>"
echo -n " <input type=button value=\"Submit\" onClick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&"
echo -n "REQUEST=password&PASSWORD=\"+encodeURIComponent(getElementById('password').value));>"
echo -n "]]></output>"
echo -n "<environments> </environments>"
echo -n "<speccreate> </speccreate>"
echo -n "<specedit> </specedit>"
echo -n "<repositories> </repositories>"
echo -n "<packages> </packages>"
echo -n "<editcontrols> </editcontrols>"
echo -n "<editor> </editor>"
echo -n "<operationpanel> </operationpanel>"
echo -n "</webbuild>"
exit
fi
fi
fi
if [ "$USER_ENABLED" != "1" ]; then
echo -n "<environments> </environments>"
echo -n "<speccreate> </speccreate>"
echo -n "<specedit> </specedit>"
echo -n "<repositories> </repositories>"
echo -n "<packages> </packages>"
echo -n "<editcontrols> </editcontrols>"
echo -n "<editor> </editor>"
if [ "$USER" -a "$SECRET" ]; then
if [ "$REQUEST" = "enablerequest" ]; then
echo "`date` - USER=$USER USER_EMAIL=$USER_EMAIL REQUEST=$REQUEST SECRET=$SECRET" >> $STATEDIR/requests_log
echo -n "<output>Your request has been submitted. Please wait for approval and retry later.</output>"
elif [ "$REQUEST" = "password" ]; then
echo -n "<output>Invalid password. Please reload and retry or ask the maintainer in case of problems.</output>"
elif [ "`grep \" USER=$USER \" $STATEDIR/requests_log`" ]; then
echo -n "<output>Your request is pending for approval. Please try again later or ask the maintainer in case of problems.</output>"
else
echo -n "<output><![CDATA[Your account is not enabled to use this service!"
echo -n " <input type=button value=\"Please, enable my account to use this service\" onClick=javascript:"
echo -n "ajax_getvalues(\"REQUEST=enablerequest\");>"
echo -n "]]></output>"
fi
else
echo -n "<output>Unauthorized!</output>"
fi
echo -n "<operationpanel> </operationpanel>"
echo -n "</webbuild>"
exit
fi
echo -n "<socialbox><![CDATA["
echo -n "<div class=\"socialbox\"><div class=\"scroll-pane\">"
count=0
[ -e "$STATEDIR/social_log" ] && tail -n 100 $STATEDIR/social_log | tac | while read line; do
STYPE=
eval $line
[ "$SUSER" = "$USER" -a "$STYPE" != "broadcastmessage" ] && continue
USER_GRAVATAR=`echo -n $SEMAIL | md5sum | sed "s| .*||"`
echo -n "<div style=\"height:auto;\"><div style=\"position:relative;float:left;height:26px;width:24px;\">"
echo -n "<img src=\"http://www.gravatar.com/avatar/$USER_GRAVATAR?s=22&d='http://www.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=22'\" /></div>"
DATENOW=`date +%s`
HOURAGO=`expr \( $DATENOW - $STIME \) / 3600`
MINAGO=`expr \( $DATENOW - $STIME \) / 60 % 60`
SECAGO=`expr \( $DATENOW - $STIME \) % 60`
TIMEAGO="${SECAGO}s"
[ $MINAGO -gt 0 -o $HOURAGO -gt 0 ] && TIMEAGO="${MINAGO}m $TIMEAGO"
[ $HOURAGO -gt 0 ] && TIMEAGO="${HOURAGO}h $TIMEAGO"
echo -n "<div style=\"position:relative;float:right;height:auto;width:164px;\"><b>$SUSER</b> $STEXT <i>(${TIMEAGO} ago)</i></div></div><br>"
# echo -n "<b>$SUSER</b> $STEXT <i>(${TIMEAGO} ago)</i><br>"
count=`expr $count + 1`
[ $count -ge 10 ] && break
echo -n "<div style=\"clear:both;\"><hr></div>"
done
echo -n "</div></div>"
echo -n "]]></socialbox>"
if [ "$REQUEST" = "refresh" ]; then
echo "</webbuild>"
exit
fi
# ENVIRONMENT select
echo -n "<environments><![CDATA["
echo -n "Build environment:<select id=environment "
echo -n "onchange=javascript:ajax_getvalues(\"ENVIRONMENT=\"+this.value+\"&REQUEST=changeenvironment\");>"
echo "<option value=\"\">-- Please select a build environment --</option>"
for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do
[ "${AUTOPORT_ARCH[$i]}" ] || continue
# [ "${AUTOPORT_DISABLE[$i]}" -a "${AUTOPORT_DISABLE[$i]}" != "0" ] && continue
SELECTED=
if [ "$ENVIRONMENT" ]; then
[ "$ENVIRONMENT" = "$i" ] && SELECTED="selected=\"selected\"" || SELECTED=
else
if [ "${AUTOPORT_CHROOT_USER[$i]}" = "$USER" ]; then
SELECTED="selected=\"selected\""
ENVIRONMENT=$i
fi
fi
if [ "${AUTOPORT_CHROOT_USER[$i]}" = "$USER" -o "${AUTOPORT_CHROOT_USER[$i]}" = "contrib" -o "$USER_ALLENVIRONMENTS" ]; then
if [ "${AUTOPORT_CHROOT_USER[$i]}" = "contrib" -a ! "$ENVIRONMENT" ]; then
SELECTED="selected=\"selected\""
ENVIRONMENT=$i
fi
echo -n "<option value=\"$i\" $SELECTED>"
if [ "${AUTOPORT_CHROOT_USER[$i]}" ]; then
echo -n "${AUTOPORT_CHROOT_USER[$i]} "
else
echo "autodist "
fi
if [ "${AUTOPORT_UPDATE[$i]}" ]; then
echo -n "autoupdate"
elif [ "${AUTOPORT_CHROOT[$i]}" ]; then
echo -n "chroot"
elif [ "${AUTOPORT_NATIVE[$i]}" ]; then
echo -n "native"
elif [ "${AUTOPORT_CROSS[$i]}" ]; then
echo -n "cross"
else
echo -n "unknown type"
fi
echo -n " for ${AUTOPORT_ARCH[$i]} (${AUTOPORT_BASE_REPOSITORY[$i]} based)"
echo -n "</option>"
fi
done
echo -n "</select>"
echo -n "]]></environments>"
if [ ! "$ENVIRONMENT" ]; then
ENVIRONMENT=$DEFAULT_ENVIRONMENT
fi
if [ "${AUTOPORT_CHROOT[$ENVIRONMENT]}" ]; then
WORKINGROOT="/var/autoport/${AUTOPORT_CHROOT[$ENVIRONMENT]}/"
WORKINGHOME="/var/autoport/${AUTOPORT_CHROOT[$ENVIRONMENT]}/usr/src/"
BUILDLOGDIR="/var/autoport/${AUTOPORT_CHROOT[$ENVIRONMENT]}/home/${AUTOPORT_CHROOT_USER[$ENVIRONMENT]}/.autodist/log/"
AUTOPORTLOGDIR="/var/autoport/${AUTOPORT_CHROOT[$ENVIRONMENT]}/home/${AUTOPORT_CHROOT_USER[$ENVIRONMENT]}/.autoport/${AUTOPORT_ARCH[$ENVIRONMENT]}/"
elif [ "${AUTOPORT_NATIVE[$ENVIRONMENT]}" ]; then
WORKINGROOT="/"
WORKINGHOME=`getent passwd ${AUTOPORT_CHROOT_USER[$ENVIRONMENT]} | cut -d: -f6`
BUILDLOGDIR="/home/${AUTOPORT_CHROOT_USER[$ENVIRONMENT]}/.autodist/log/"
AUTOPORTLOGDIR="/home/${AUTOPORT_CHROOT_USER[$ENVIRONMENT]}/.autoport/${AUTOPORT_ARCH[$ENVIRONMENT]}/"
else
WORKINGROOT="/"
WORKINGHOME="/var/autodist/"
BUILDLOGDIR="/var/autodist/log/"
AUTOPORTLOGDIR="/var/autodist/.autoport/${AUTOPORT_ARCH[$ENVIRONMENT]}/"
fi
if [ "$HOST_IS_X86_64" -a "${AUTOPORT_ARCH[$ENVIRONMENT]}" != "x86_64" ]; then
SUDO_WRAPPER="linux32 $SUDO_WRAPPER"
fi
[ "$PACKAGE" -a ! "$REQUEST" ] && REQUEST=edit
# SPECFILES select
if [ "$ENVIRONMENT" ]; then
echo -n "<specedit><![CDATA["
echo -n " Edit:<select id=specfile "
echo -n "onchange=javascript:ajax_getvalues(\"REQUEST=edit&ENVIRONMENT=$ENVIRONMENT&PACKAGE=\"+this.value+\"&REQUEST=changespec\");>"
echo -n "<option value=\"\">-- Select a .spec file --</option>"
for f in `$SUDO_WRAPPER $ENVIRONMENT "" "ls *.spec"`; do
specname=${f/.*}
[ "$PACKAGE" = "$specname" ] && SELECTED="selected=\"selected\"" || SELECTED=
echo -n "<option value=\"$specname\" $SELECTED>${specname}.spec</option>"
done
echo -n "</select>]]></specedit>"
fi
# clean output when changing environment
if [ ! "$REPOSITORY" -a ! "$PACKAGE" -a ! "$REQUEST" = "repsearch" ]; then
echo -n "<editor> </editor>"
# echo -n "<editor><![CDATA[<textarea id=spectext class=editor disabled=true></textarea>]]></editor>"
echo -n "<output><![CDATA[<div align=left class=output id=outputbottom>]]></output>"
fi
# REPOSITORIES search
if [ ! "$REPSEARCHTEXT" ]; then
echo -n "<searchbox><![CDATA["
echo -n "<div class=searchbox><input type=button id=repsearchbutton value=\"Search repositories:\" onclick=javascript:ajax_getvalues(\""
echo -n "ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&"
echo -n "REQUEST=repsearch&REPSEARCHTEXT=\"+encodeURIComponent(getElementById('repsearchtext').value));>"
if [ "$PACKAGE" ]; then
echo -n "<input type=text id=repsearchtext value=\"${PACKAGE}-\" size=\"15\">"
else
echo -n "<input type=text id=repsearchtext value=\"\" size=\"15\">"
fi
echo -n "</div>]]></searchbox>"
fi
# REPOSITORIES select
if [ ! "$REPOSITORY" ]; then
echo -n "<repositories><![CDATA[Repository:<select id=repository "
echo -n "onchange=javascript:ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=\"+this.value+\""
if [ "$USER_CANIMPORT" ]; then
echo -n "&MAINTAINERMODE=\"+getElementById('maintain').checked+\""
fi
echo -n "&PACKAGE=$PACKAGE&REQUEST=changerepository\");>"
echo -n "<option value=\"\">-- Select a repository --</option>"
for f in `$SUDO_WRAPPER local "" "/usr/sbin/openmamba-repository list"`; do
repname=`basename $f`
echo -n "<option value=\"$repname\">$repname</option>"
done
echo -n "</select>"
if [ "$USER_CANIMPORT" ]; then
[ "$MAINTAINERMODE" = "true" ] && CHECKED="checked"
echo -n "<input type=checkbox id=\"maintain\" $CHECKED "
echo -n "onclick=javascript:i=getElementById('repository').selectedIndex;"
echo -n "ajax_getvalues(\"REPOSITORY=\"+getElementById('repository').options[i].text+\""
echo -n "&MAINTAINERMODE=\"+getElementById('maintain').checked+\""
echo -n "&PACKAGE=$PACKAGE&ENVIRONMENT=$ENVIRONMENT\");>maintainer mode "
fi
echo -n "]]></repositories>"
echo -n "<packages> </packages>"
echo -n "<operations> </operations>"
fi
# PACKAGES (SRPM) select
if [ "$REPOSITORY" -a "$REQUEST" = "changerepository" ]; then
echo -n "<packages><![CDATA["
echo -n "<select id=package "
echo -n "onchange=javascript:i=getElementById('repository').selectedIndex;ajax_getvalues(\"REQUEST=changesrpm&"
echo -n "ENVIRONMENT=$ENVIRONMENT&MAINTAINERMODE=\"+getElementById('maintain').checked+\"&PACKAGE=\"+this.value+\""
echo -n "&REPOSITORY=\"+getElementById('repository').options[i].text);>"
echo "<option value=\"\">-- Select a SRPM package --</option>"
for f in $local_ftp/$REPOSITORY/SRPMS.base/*.src.rpm; do
[ -r $f ] || continue
pkgname=`basename $f`
pkgname=${pkgname/.src.rpm}
pkgrel=${pkgname/*-}
pkgname=${pkgname/-$pkgrel}
pkgver=${pkgname/*-}
pkgname=${pkgname/-$pkgver}
if [ "$PACKAGE" = "$pkgname" ]; then
SELECTED="selected=\"selected\"";
REQUEST="changesrpm"
else
SELECTED=
fi
echo -n "<option value=\"$pkgname\" $SELECTED>${pkgname} ${pkgver}-${pkgrel}</option>"
done
echo -n "</select>"
echo "]]></packages>"
REQUEST=changesrpm
fi
# SPECFILE creation
if [ ! "$REQUEST" ]; then
echo -n "<speccreate><![CDATA["
echo -n " Start from URL:<input type=text id=speccreateurl value=\"\" size=\"55\">"
echo -n " name:<input type=text id=speccreatename value=\"\" size=\"10\">"
echo -n " type:<select id=speccreatetype>"
for t in standard gnome kde3 kde4 library perl python standard-daemon; do
echo -n "<option value=\"$t\">$t</option>"
done
echo -n "</select>"
echo -n " version:<input type=text id=speccreateversion value=\"\" size=\"6\">"
echo -n "<input type=button id=speccreatebutton value=\"Create .spec\" onclick=javascript:ajax_getvalues(\""
echo -n "REQUEST=speccreate&ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&"
echo -n "PACKAGE=\"+getElementById('speccreatename').value+\"&"
echo -n "SPECCREATETYPE=\"+getElementById('speccreatetype').value+\"&"
echo -n "SPECCREATEVERSION=\"+getElementById('speccreateversion').value+\"&"
echo -n "SPECCREATEURL=\"+encodeURIComponent(getElementById('speccreateurl').value));>"
echo "]]></speccreate>"
fi
if [ "$REQUEST" = "changesrpm" ]; then
if [ "$PACKAGE" ]; then
echo -n "<operations><![CDATA["
if [ "$MAINTAINERMODE" != "true" ]; then
echo -n "<input type=button name=prepare value=\"prepare\" "
echo -n "onclick=javascript:i=getElementById('repository').selectedIndex;j=getElementById('package').selectedIndex;"
echo -n "ajax_getvalues(\"REQUEST=prepare&REPOSITORY=\"+getElementById('repository').options[i].value+\""
echo -n "&ENVIRONMENT=$ENVIRONMENT&MAINTAINERMODE=\"+getElementById('maintain').checked+\"&PACKAGE=\"+getElementById('package').options[j].value);>"
fi
echo "]]></operations>"
REQUEST="edit"
else
echo "<operations> </operations>"
fi
elif [ "$REQUEST" = "changespec" ]; then
if [ "$PACKAGE" ]; then
REQUEST="edit";
fi
elif [ "$REQUEST" = "broadcastmessage" ]; then
BROADCASTMESSAGE=`echo $BROADCASTMESSAGE | sed "s|<|\&lt;|g"`
echo "SUSER=$USER STYPE=broadcastmessage SEMAIL=$USER_EMAIL STEXT=\"said:&quot;<i>$BROADCASTMESSAGE</i>&quot;\" STIME=`date +%s`" >> $STATEDIR/social_log
REQUEST=
fi
if [ ! "$PACKAGE" -a "$MAINTAINERMODE" != "true" ]; then
echo "<editor> </editor>"
echo "<editcontrols> </editcontrols>"
echo "<operationpanel> </operationpanel>"
fi
if [ "$SPECTEXT" ]; then
# save specfile
tmpfile=`mktemp`
echo -n $SPECTEXT | perl -MURI::Escape -e 'print uri_unescape(<>)' > $tmpfile
chmod 644 $tmpfile
$SUDO_WRAPPER $ENVIRONMENT $PACKAGE "cat $tmpfile > $PACKAGE.spec" $tmpfile
rm -f $tmpfile
fi
# Here requests which update the specfile, so editor is refreshed after
if [ "$REQUEST" = "prepare" -o "$REQUEST" = "updatespec" -o "$REQUEST" = "speccreate" -o \
"$REQUEST" = "rebuildspec" -o "$REQUEST" = "renamespec" ]; then
echo -n "<output><![CDATA[<div align=left class=output id=outputbottom>"
echo -n "<pre>"
RET=255
case $REQUEST in
"prepare") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a1 --server $REPOSITORY"; RET=$? ;;
"updatespec") if [ "$UPDATESSPECVERSION" -a "$REBUILDSPECCHANGELOG" ]; then
echo "ERROR: new version and changelog can't be specified together"
elif [ "$REBUILDSPECCHANGELOG" ]; then
$SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a4 --rebuild --changelog \"$REBUILDSPECCHANGELOG\""
elif [ "$UPDATESSPECVERSION" ]; then
$SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a3,4 $UPDATESPECVERSION"
else
$SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a2:4 $UPDATESPECVERSION"
fi
RET=$? ;;
"speccreate") if [ "$SPECCREATEURL" -a "$PACKAGE" ]; then
AUTOSPEC_CMDLINE="-n $PACKAGE -o $PACKAGE.spec"
#DECODEDURL=`cgi_decodevar $SPECCREATEURL`
[ "$SPECCREATETYPE" ] && AUTOSPEC_CMDLINE="$AUTOSPEC_CMDLINE -t $SPECCREATETYPE"
[ "$SPECCREATEVERSION" ] && AUTOSPEC_CMDLINE="$AUTOSPEC_CMDLINE -v $SPECCREATEVERSION"
$SUDO_WRAPPER $ENVIRONMENT "" "autospec -s \"$SPECCREATEURL\" $AUTOSPEC_CMDLINE"
RET=$?
# --changelog \"package created by $USER from autodist webbuild interface\""
else
echo "ERROR: both source archive URL and name are needed."
RET=1
fi
;;
"renamespec") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "mv $RENAMESPECFROM.spec $PACKAGE.spec && sed -i \"s|\(Name:[[:space:]]*\).*|\1$PACKAGE|\" $PACKAGE.spec"
RET=$?
;;
esac
echo -n "</pre>"
if [ $RET -eq 0 ]; then
echo "Result: <font color=green><b>OK</b></font>"
else
echo "Result: <font color=red><b>ERROR ($RET)</b></font>"
fi
echo -n "</div>"
echo -n "]]></output>"
REQUEST="edit"
fi
if [ "$REPOSITORY" != "" -a "$MAINTAINERMODE" = "true" ]; then
echo -n "<editcontrols> </editcontrols>"
echo -n "<editor><![CDATA["
echo -n "<div class=maintainer>"
echo -n "<b>Recent packages in $REPOSITORY:</b><br>"
cat $local_ftp/distromatic/$REPOSITORY/_recent.inc
echo -n "<br><b>Log:</b><br><pre>"
cat $local_ftp/$REPOSITORY/distromatic.log
echo -n "</pre></div>"
echo -n "]]></editor>"
fi
if [ "$REQUEST" = "edit" -o "$REQUEST" = "reloadspec" ]; then
if [ "$PACKAGE" ]; then
$SUDO_WRAPPER $ENVIRONMENT $PACKAGE "ls $PACKAGE.spec"
[ $? -eq 0 ] && SPECAVAILABLE=1
fi
if [ "$MAINTAINERMODE" != "true" -a "$SPECAVAILABLE" ]; then
if [ "$REQUEST" = "edit" ]; then
echo "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"is working on <b>$PACKAGE</b>\" STIME=`date +%s`" >> $STATEDIR/social_log
fi
echo -n "<editcontrols><![CDATA[Current <b>$PACKAGE.spec</b> in build environment: "
echo -n "new version (empty=autodetect):<input type=text id=updatespecversion value=\"\" size=\"12\">"
# echo -n " <input type=button id=rebuildspecbutton value=\"new release\" onclick=javascript:"
# echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&"
# echo -n "REQUEST=rebuildspec&REBUILDSPECCHANGELOG=\"+getElementById('rebuildspecchangelog').value+\"&"
# echo -n "SPECTEXT=\"+encodeURIComponent(editor.getValue())); class=redbutton>"
echo -n "or new release changelog:<input type=text id=rebuildspecchangelog value=\"$REBUILDSPECCHANGELOG\" size=\"30\">"
echo -n "<input type=button id=updatespecbutton value=\"update .spec\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&"
echo -n "REQUEST=updatespec&UPDATESPECVERSION=\"+getElementById('updatespecversion').value+\"&"
echo -n "REBUILDSPECCHANGELOG=\"+encodeURIComponent(getElementById('rebuildspecchangelog').value)+\"&"
echo -n "SPECTEXT=\"+encodeURIComponent(editor.getValue()));>"
echo -n "]]></editcontrols>"
echo -n "<editor><![CDATA[<textarea id=spectext "
echo -n "onkeyup=\"getElementById('savebutton').disabled=false;getElementById('savebutton').class='redbutton';\" class=editor>"
$SUDO_WRAPPER $ENVIRONMENT $PACKAGE "cat $PACKAGE.spec"
echo -n "</textarea>"
echo -n "<input type=button id=savebutton value=\"save\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&"
echo -n "REQUEST=savespec&SPECTEXT=\"+encodeURIComponent(editor.getValue()));"
echo -n "this.disabled=true; disabled=disabled class=redbutton>"
echo -n "<input type=button id=updatespecbutton value=\"reload\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&"
echo -n "REQUEST=reloadspec\");>"
echo -n "<input type=button id=updatespecbutton value=\"rename to:\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&RENAMESPECFROM=$PACKAGE&"
echo -n "REQUEST=renamespec&PACKAGE=\"+getElementById('specnewname').value);>"
echo -n "<input type=text id=specnewname value=\"\" size=\"10\">.spec"
echo -n "]]></editor>"
fi
if [ "$MAINTAINERMODE" = "true" -o "$SPECAVAILABLE" ]; then
echo -n "<operationpanel><![CDATA[<hr>"
if [ "$MAINTAINERMODE" != "true" ]; then
if [ "${AUTOPORT_UPDATE[$ENVIRONMENT]}" -o "${AUTOPORT_CHROOT[$ENVIRONMENT]}" ]; then
echo -n "<b>Last logs:</b> "
echo -n "OK <input id=\"logstatusOK\" type=\"radio\" name=\"logstatus\" value=\"OK\"> "
echo -n "FAILED<input type=\"radio\" name=\"logstatus\" value=\"FAILED\" checked=\"checked\"><br>"
echo -n "<input type=button value=\"prepare\" onclick=javascript:ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&PACKAGE=$PACKAGE&"
echo -n "REQUEST=showlog&LOGTYPE=prepare&LOGSTATUSOK=\"+document.all.logstatusOK.checked);>"
echo -n "<input type=button value=\"update\" onclick=javascript:ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&PACKAGE=$PACKAGE&"
echo -n "REQUEST=showlog&LOGTYPE=update&LOGSTATUSOK=\"+document.all.logstatusOK.checked);>"
echo -n "<input type=button value=\"build\" onclick=javascript:ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&PACKAGE=$PACKAGE&"
echo -n "REQUEST=showlog&LOGTYPE=build&LOGSTATUSOK=\"+document.all.logstatusOK.checked);>"
echo -n "<input type=button value=\"install\" onclick=javascript:ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&PACKAGE=$PACKAGE&"
echo -n "REQUEST=showlog&LOGTYPE=install&LOGSTATUSOK=\"+document.all.logstatusOK.checked);>"
if [ "${AUTOPORT_UPDATE[$ENVIRONMENT]}" ]; then
echo -n "<hr><b>Scheduled builds:</b><br>"
echo -n "<input type=button value=\"show\" onclick=javascript:ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&PACKAGE=$PACKAGE&"
echo -n "REQUEST=showscheduled\");>"
echo -n "<input type=button value=\"unschedule\" onclick=javascript:ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&PACKAGE=$PACKAGE&"
echo -n "REQUEST=unschedule\"); class=redbutton>"
echo -n "<input type=button value=\"skip\" onclick=javascript:ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&PACKAGE=$PACKAGE&"
echo -n "REQUEST=skip\"); class=redbutton>"
fi
echo -n "<hr>"
fi
echo -n "<b>RPM packaging commands:</b><br>"
echo -n "<input type=button value=\"check for updates\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&REQUEST=autospecupdatescheck\");>"
echo -n "<input type=button value=\"unpack\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&REQUEST=rpmprepare&"
echo -n "SPECTEXT=\"+encodeURIComponent(editor.getValue()));>"
echo -n "<input type=button value=\"build\" onclick=javascript:"
echo -n "i=getElementById('rpmbuildarch').selectedIndex;"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&REQUEST=rpmbuild&"
echo -n "RPMBUILDARCH=\"+getElementById('rpmbuildarch').options[i].value+\"&"
echo -n "SPECTEXT=\"+encodeURIComponent(editor.getValue())+\"&RPMFORCE=\"+getElementById('rpmforce').checked); class=boldbutton>"
echo -n "<input type=button value=\"buildroot files\" onclick=javascript:"
echo -n "i=getElementById('rpmbuildarch').selectedIndex;"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&REQUEST=buildrootfiles\");>"
echo -n "<input type=button value=\"unpackaged files\" onclick=javascript:"
echo -n "i=getElementById('rpmbuildarch').selectedIndex;"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&REQUEST=autospeclistcheck&"
echo -n "RPMBUILDARCH=\"+getElementById('rpmbuildarch').options[i].value+\"&"
echo -n "SPECTEXT=\"+encodeURIComponent(editor.getValue()));>"
echo -n "<input type=button value=\"build requirements\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&REQUEST=autospecbuildreq\");>"
echo -n "<input type=button value=\"rebuild SRPM\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&REQUEST=srpmbuild&"
echo -n "SPECTEXT=\"+encodeURIComponent(editor.getValue())+\"&RPMFORCE=\"+getElementById('rpmforce').checked);>"
echo -n "<input type=button id=rpmchecks value=\"checks\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&REQUEST=rpmchecks\");>"
echo -n "<input type=button id=rpmsimulateinstallbutton value=\"simulate install\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&REQUEST=rpmsimulateinstall\");>"
[ ! "$USER_CANINSTALL" ] && DISABLED="disabled=disabled"
echo -n "<input type=button id=rpminstallbutton value=\"install\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&REQUEST=rpminstall&"
echo -n "RPMFORCE=\"+getElementById('rpmforce').checked); class=redbutton $DISABLED>"
echo -n "<br>target arch:<select id=rpmbuildarch>"
for f in i586 arm x86_64 ppc; do
SELECTED=
if [ ! "$RPMBUILDARCH" -a "$f" = "${AUTOPORT_ARCH[$ENVIRONMENT]}" ]; then
SELECTED="selected=\"selected\"";
fi
echo -n "<option value=\"$f\" $SELECTED>$f</option>"
done
echo -n "</select>"
echo -n "<label style=\"vertical-align:middle;\"><input type=checkbox id=\"rpmforce\" value=\"force\">force</label>"
echo -n "<hr><b>Add patches:</b>"
echo -n "<input type=button id=addpatchbutton value=\"submit\" onclick=javascript:ajax_getvalues(\""
echo -n "REQUEST=addpatch&ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&"
echo -n "ADDPATCHURL=\"+encodeURIComponent(getElementById('addpatchurl').value)+\"&"
echo -n "ADDPATCHNAME=\"+encodeURIComponent(getElementById('addpatchname').value));><br>"
echo -n "URL:<input type=text id=addpatchurl value=\"\" size=\"28\">"
echo -n "As: $PACKAGE-<input type=text id=addpatchname value=\"\" size=\"13\">.patch"
echo -n "<hr><b>Repository:</b>"
echo -n "<select id=sendrepository>"
for f in `$SUDO_WRAPPER local "" "/usr/sbin/openmamba-repository list"`; do
repname=`basename $f`
if [ "$repname" = "devel-${AUTOPORT_CHROOT_USER[$ENVIRONMENT]}" -o \
"$repname" = "${AUTOPORT_BASE_REPOSITORY[$ENVIRONMENT]}" -o \
"$repname" = "devel-$USER" -o \
"$USER_ALLREPOSITORIES" ]; then
SELECTED=
if [ "$SENDREPOSITORY" = "$repname" ]; then
SELECTED="selected=\"selected\"";
elif [ ! "$SENDREPOSITORY" -a "${AUTOPORT_BASE_REPOSITORY[$ENVIRONMENT]}" = "$repname" ]; then
SELECTED="selected=\"selected\"";
fi
echo -n "<option value=\"$repname\" $SELECTED>$repname</option>"
fi
done
echo -n "</select>"
echo -n "<br><input type=button id=sendpackagebutton value=\"send\" onclick=javascript:"
echo -n "i=getElementById('sendrepository').selectedIndex;"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&REQUEST=sendpackage&"
echo -n "SENDREPOSITORY=\"+getElementById('sendrepository').options[i].value); class=redbutton>"
# echo -n "<input type=button id=updatesourcebutton value=\"recreate SRPM\" onclick=javascript:"
# echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&"
# echo -n "REQUEST=updatesource&SPECTEXT=\"+encodeURIComponent(editor.getValue()));getElementById('sendsourcebutton').disabled=false;>"
echo -n "<input type=button id=sendsourcebutton value=\"rebuild and send SRPM\" onclick=javascript:i=getElementById('sendrepository').selectedIndex;"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&REQUEST=sendsource&"
echo -n "SPECTEXT=\"+encodeURIComponent(editor.getValue())+\""
echo -n "SENDREPOSITORY=\"+getElementById('sendrepository').options[i].value); class=redbutton>"
fi
if [ "$USER_CANIMPORT" -a "$PACKAGE" ]; then
if [ "$MAINTAINERMODE" = "true" ]; then
echo -n "<hr><b>Repository maintenance:</b><br>"
echo -n "Package: $PACKAGE<br>"
echo -n "Source: $REPOSITORY<br>"
echo -n "Destination: "
echo -n "<select id=repositoryimportto>"
for f in ${AUTOPORT_IMPORT_REPOSITORIES[$ENVIRONMENT]}; do
if [ "$MAINTAINERMODE" = "true" ]; then
[ "$f" != "$REPOSITORY" ] && echo -n "<option value=\"$f\">$f</option>"
else
[ "$f" != "${AUTOPORT_BASE_REPOSITORY[$ENVIRONMENT]}" ] && echo -n "<option value=\"$f\">$f</option>"
fi
done
echo -n "</select><br>"
fi
if [ "$MAINTAINERMODE" != "true" ]; then
echo -n "<input type=button value=\"archive\" onclick=javascript:"
echo -n "i=getElementById('sendrepository').selectedIndex;"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&"
echo -n "MAINTAINERMODE=\"+getElementById('maintain').checked+\"&"
echo -n "SENDREPOSITORY=\"+getElementById('sendrepository').options[i].value+\"&"
echo -n "REPOSITORYSIMULATE=\"+getElementById('repositorysimulate').checked+\"&"
echo -n "REQUEST=repositoryarchive\"); class=redbutton>"
echo -n "<hr><input type=button value=\"import to:\" onclick=javascript:"
echo -n "i=getElementById('repositoryimportto').selectedIndex;j=getElementById('sendrepository').selectedIndex;"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&"
echo -n "REPOSITORYIMPORTTO=\"+getElementById('repositoryimportto').options[i].value+\"&"
echo -n "REPOSITORYSIMULATE=\"+getElementById('repositorysimulate').checked+\"&"
echo -n "SENDREPOSITORY=\"+getElementById('sendrepository').options[j].value+\"&"
echo -n "REQUEST=repositoryimport\");>"
echo -n "<select id=repositoryimportto>"
for f in ${AUTOPORT_IMPORT_REPOSITORIES[$ENVIRONMENT]}; do
if [ "$MAINTAINERMODE" = "true" ]; then
[ "$f" != "$REPOSITORY" ] && echo -n "<option value=\"$f\">$f</option>"
else
[ "$f" != "${AUTOPORT_BASE_REPOSITORY[$ENVIRONMENT]}" ] && echo -n "<option value=\"$f\">$f</option>"
fi
done
echo -n "</select>"
else
# repository compare
echo -n "<input type=button value=\"compare\" onclick=javascript:"
echo -n "i=getElementById('repositoryimportto').selectedIndex;"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&"
echo -n "MAINTAINERMODE=\"+getElementById('maintain').checked+\"&"
echo -n "REPOSITORYIMPORTTO=\"+getElementById('repositoryimportto').options[i].value+\"&"
echo -n "REPOSITORYSIMULATE=\"+getElementById('repositorysimulate').checked+\"&"
echo -n "SENDREPOSITORY=$REPOSITORY&REQUEST=repositorydiff\");>"
# repository import
echo -n "<input type=button value=\"import\" onclick=javascript:"
echo -n "i=getElementById('repositoryimportto').selectedIndex;"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&"
echo -n "MAINTAINERMODE=\"+getElementById('maintain').checked+\"&"
echo -n "REPOSITORYIMPORTTO=\"+getElementById('repositoryimportto').options[i].value+\"&"
echo -n "REPOSITORYSIMULATE=\"+getElementById('repositorysimulate').checked+\"&"
echo -n "SENDREPOSITORY=$REPOSITORY&REQUEST=repositoryimport\"); class=redbutton>"
# repository release
echo -n "<input type=button value=\"release\" onclick=javascript:"
echo -n "i=getElementById('repositoryimportto').selectedIndex;"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&"
echo -n "MAINTAINERMODE=\"+getElementById('maintain').checked+\"&"
echo -n "REPOSITORYIMPORTTO=\"+getElementById('repositoryimportto').options[i].value+\"&"
echo -n "REPOSITORYSIMULATE=\"+getElementById('repositorysimulate').checked+\"&"
echo -n "SENDREPOSITORY=$REPOSITORY&REQUEST=repositoryrelease\"); class=redbutton>"
# repository archive
echo -n "<input type=button value=\"archive\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&"
echo -n "MAINTAINERMODE=\"+getElementById('maintain').checked+\"&"
echo -n "SENDREPOSITORY=$REPOSITORY&"
echo -n "REPOSITORYSIMULATE=\"+getElementById('repositorysimulate').checked+\"&"
echo -n "REQUEST=repositoryarchive\"); class=redbutton>"
fi
echo -n "<br><input type=checkbox id=\"repositorysimulate\" value=\"simulate\">simulate</label>"
fi
if [ "$MAINTAINERMODE" != "true" ]; then
if [ ! "${AUTOPORT_DISABLE[$ENVIRONMENT]}" -a ! "${AUTOPORT_UPDATE[$ENVIRONMENT]}" ]; then
echo -n "<hr>Automatic port:<br>"
echo -n "<input type=button id=autoportnp value=\"port\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&REQUEST=autoportnp\"); class=boldbutton>"
echo -n "<input type=button id=autoportlog value=\"log\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&REQUEST=autoportlog\");>"
# echo -n "<br>Last logs: "
# echo -n "OK <input id=\"logstatusOK\" type=\"radio\" name=\"logstatus\" value=\"OK\"> "
# echo -n "FAILED<input type=\"radio\" name=\"logstatus\" value=\"FAILED\" checked=\"checked\"><br>"
# echo -n "<input type=button value=\"build\" onclick=javascript:ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&PACKAGE=$PACKAGE&"
# echo -n "REQUEST=showlog&LOGTYPE=build&LOGSTATUSOK=\"+document.all.logstatusOK.checked);>"
# echo -n "<input type=button value=\"install\" onclick=javascript:ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&PACKAGE=$PACKAGE&"
# echo -n "REQUEST=showlog&LOGTYPE=install&LOGSTATUSOK=\"+document.all.logstatusOK.checked);>"
fi
if [ "${AUTOPORT_UPDATE[$ENVIRONMENT]}" ]; then
echo -n "<hr><b>Autodist:</b><br>"
echo -n "Patch:<input type=button value=\"show\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&"
echo -n "REQUEST=showpatch\");>"
echo -n "<input type=button value=\"remove\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&"
echo -n "REQUEST=removepatch\"); class=redbutton>"
echo -n "<input type=button id=updatepatchbutton value=\"update\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&"
echo -n "SPECTEXT=\"+encodeURIComponent(editor.getValue())+\"&"
echo -n "REQUEST=updatepatch\"); class=redbutton>"
echo -n "<input type=button id=buildpatchbutton value=\"build\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&"
echo -n "SPECTEXT=\"+encodeURIComponent(editor.getValue())+\"&"
echo -n "REQUEST=buildpatch\"); class=redbutton>"
fi
echo -n "<hr><b>Info:</b><br>"
echo -n "<input type=button value=\"allowed groups\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&REQUEST=allowedgroups\");>"
echo -n "<input type=button value=\"approved licenses\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&REQUEST=approvedlicenses\");>"
echo -n "<input type=button value=\"builddir files\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&REQUEST=builddirfiles\");>"
echo -n "<input type=button value=\"configure help\" onclick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&REQUEST=configurehelp\");>"
echo -n "<div style=\"nowrap;\"><input type=button id=sendsourcebutton value=\"macros:\" onclick=javascript:i=getElementById('macrosfile').selectedIndex;"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&REQUEST=showmacrosfile&"
echo -n "MACROSFILE=\"+getElementById('macrosfile').options[i].value);>"
echo -n "<select id=macrosfile>"
for f in $WORKINGROOT/etc/rpm/macros.*; do
macrosfilename=`basename $f`
macrosfile=`echo $macrosfilename | sed "s|macros\.||"`
echo -n "<option value=\"$macrosfile\">$macrosfile</option>"
done
echo -n "</select></div>"
fi
echo -n "<hr><b>Broadcast message:</b><br>"
echo -n "<input type=text id=broadcastmessage size=\"25\">"
echo -n "<input type=button value=\"send\" onClick=javascript:"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&"
echo -n "REQUEST=broadcastmessage&BROADCASTMESSAGE=\"+encodeURIComponent(getElementById('broadcastmessage').value));"
echo -n "getElementById('broadcastmessage').value=\"\";>"
echo -n "]]></operationpanel>"
else
echo "<output><![CDATA[<div align=left class=output id=outputtop>"
echo "No pre-existing .spec file $PACKAGE.spec in current working environment. Use 'prepare' to edit."
echo -n "</div>"
echo -n "]]></output>"
fi
elif [ "$REQUEST" = "showlog" ]; then
echo -n "<output><![CDATA["
LOGFILE=$LOGTYPE
if [ "$LOGSTATUSOK" = "true" ]; then
LOGFILE=$LOGFILE/ok
else
LOGFILE=$LOGFILE/failed
fi
LOGFILE1=$LOGFILE/$PACKAGE.${AUTOPORT_ARCH[$ENVIRONMENT]}
LOGFILE2=$LOGFILE/${PACKAGE}__*.${AUTOPORT_ARCH[$ENVIRONMENT]}
LOGFILE3=$LOGFILE/*_${PACKAGE}__*.${AUTOPORT_ARCH[$ENVIRONMENT]}
LOGFILE4=$LOGFILE/*_${PACKAGE}.${AUTOPORT_ARCH[$ENVIRONMENT]}
LOGFILE1=$BUILDLOGDIR/$LOGFILE1
LOGFILE2=$BUILDLOGDIR/$LOGFILE2
LOGFILE3=$BUILDLOGDIR/$LOGFILE3
LOGFILE4=$BUILDLOGDIR/$LOGFILE4
echo "<div align=left class=output id=outputbottom>"
for f in $LOGFILE1 $LOGFILE2 $LOGFILE3 $LOGFILE4; do
[ -r $f ] || continue
echo "<b>`basename $f` (`stat -c %y $f`)</b><pre>"
cat $f | sed "s|<|\&lt;|g"
echo -n "</pre>"
done
echo -n "</div>]]></output>"
else
if [ "$REQUEST" != "" ]; then
echo -n "<output><![CDATA["
echo "<div align=left class=output "
if [ "$REQUEST" = "rpmbuild" -o "$REQUEST" = "autoportnp" -o "$REQUEST" = "rpmprepare" \
-o "$REQUEST" = "sendpackage" -o "$REQUEST" = "sendsource" ]; then
echo -n "id=outputbottom"
else
echo -n "id=outputtop"
fi
echo "><pre><!-- SCROLL -->"
RET=255
fi
case $REQUEST in
"showpatch") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autodist-tool makepatch $PACKAGE"; RET=$? ;;
"removepatch") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autodist-tool makepatch $PACKAGE remove"
RET=$?
if [ $RET -eq 0 ]; then
echo "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"removed the autodist patch for <b>$PACKAGE</b>\" STIME=`date +%s`" >> $STATEDIR/social_log
fi ;;
"updatepatch") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autodist-tool makepatch $PACKAGE update"
RET=$?
if [ $RET -eq 0 ]; then
echo "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"made an autodist <b>update</b> patch for <b>$PACKAGE</b>\" STIME=`date +%s`" >> $STATEDIR/social_log
fi ;;
"buildpatch") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autodist-tool makepatch $PACKAGE build"
RET=$?
if [ $RET -eq 0 ]; then
echo "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"made an autodist <b>build</b> patch for <b>$PACKAGE</b>\" STIME=`date +%s`" >> $STATEDIR/social_log
fi ;;
"showscheduled") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autodist-tool schedule"; RET=$? ;;
"unschedule") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autodist-tool unschedule $PACKAGE"
RET=$?
if [ $RET -eq 0 ]; then
echo "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"unscheduled autodist job <b>$PACKAGE</b>\" STIME=`date +%s`" >> $STATEDIR/social_log
fi ;;
"skip") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autodist-tool skip $PACKAGE"
RET=$?
if [ $RET -eq 0 ]; then
echo "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"added autodist job <b>$PACKAGE</b> to skipped list\" STIME=`date +%s`" >> $STATEDIR/social_log
fi ;;
"buildrootfiles") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "cd @RPMBUILDROOT@ && find @BUILDROOT@"; RET=$? ;;
"autospecupdatescheck") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a2"; RET=$? ;;
"rpmprepare") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "rpmbuild -bp $PACKAGE.spec"; RET=$? ;;
"rpmbuild") echo "`date` - RPMBUILD=$PACKAGE USER=$USER ENVIRONMENT=$ENVIRONMENT" >> $STATEDIR/buildingnow_log
[ "$RPMFORCE" = "true" ] && RPMFORCEADD="--force-build"
[ "$RPMBUILDARCH" -a "$RPMBUILDARCH" != "${AUTOPORT_ARCH[$ENVIRONMENT]}" ] && \
RPMARCHADD="-A $RPMBUILDARCH --define \"cross_target_cpu=$RPMBUILDARCH\""
$SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a5 $RPMFORCEADD $RPMARCHADD"
RET=$?
if [ $RET -eq 0 ]; then
echo "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"successfully built <b>$PACKAGE</b>\" STIME=`date +%s`" >> $STATEDIR/social_log
fi
sed -i "|RPMBUILD=$PACKAGE USER=$USER ENVIRONMENT=$ENVIRONMENT|d" $STATEDIR/buildingnow_log
#kill `pstree -p 25541 | sed 's/(/\n(/g' | grep '(' | sed 's/(\(.*\)).*/\1/' | tr "\n" " "`
;;
"srpmbuild") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "rpmbuild -bs $PACKAGE.spec"
RET=$? ;;
"autospeclistcheck")
[ "$RPMBUILDARCH" -a "$RPMBUILDARCH" != "${AUTOPORT_ARCH[$ENVIRONMENT]}" ] && \
RPMARCHADD="-A $RPMBUILDARCH --define \"cross_target_cpu=$RPMBUILDARCH\""
$SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a5 --list-check $RPMARCHADD"
RET=$? ;;
"autospecbuildreq") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a6"
RET=$? ;;
"rpmchecks") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a8"; RET=$? ;;
"rpmsimulateinstall") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a7"; RET=$? ;;
"rpminstall") if [ "$USER_CANINSTALL" ]; then
[ "$RPMFORCE" = "true" ] && RPMFORCEADD="--force-install"
$SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a11 $RPMFORCEADD"; RET=$?
else
echo "Install function disabled."
RET=1
fi ;;
"addpatch") if [ "$ADDPATCHURL" -a "$ADDPATCHNAME" ]; then
$SUDO_WRAPPER $ENVIRONMENT $PACKAGE "curl \"$ADDPATCHURL\" -o ../SOURCES/$PACKAGE-$ADDPATCHNAME.patch"
RET=$?
[ $RET -eq 0 ] && echo "Patch added with name $PACKAGE-$ADDPATCHNAME.patch"
else
echo "Patch URL or destination name not provided."
RET=1
fi ;;
"sendpackage") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autospec -u $PACKAGE -a10 --server $SENDREPOSITORY"
RET=$?
if [ $RET -eq 0 ]; then
echo "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"sent <b>$PACKAGE</b> to <b>$SENDREPOSITORY</b>\" STIME=`date +%s`" >> $STATEDIR/social_log
fi ;;
"sendsource") [ "$RPMFORCE" = "true" ] && RPMFORCEADD="--force --nodeps"
$SUDO_WRAPPER $ENVIRONMENT $PACKAGE "rpmbuild -bs $PACKAGE.spec && autospec -u $PACKAGE -a10 --server $SENDREPOSITORY --norpm"
RET=$? ;;
"repositoryimport")
[ "$REPOSITORYSIMULATE" = "true" -o ! "$USER_CANIMPORT" ] && SIMULATEADD="-s" || SIMULATEADD=
$SUDO_WRAPPER local $PACKAGE "openmamba-repository import $SENDREPOSITORY $PACKAGE -d $REPOSITORYIMPORTTO $SIMULATEADD -y"
RET=$?
if [ ! "$SIMULATEADD" -a $RET -eq 0 ]; then
echo "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"imported <b>$PACKAGE</b> from <b>$SENDREPOSITORY</b> to <b>$REPOSITORYIMPORTTO</b>\" STIME=`date +%s`" >> $STATEDIR/social_log
fi
;;
"repositoryrelease")
[ "$REPOSITORYSIMULATE" = "true" -o ! "$USER_CANIMPORT" ] && SIMULATEADD="-s" || SIMULATEADD=
$SUDO_WRAPPER local $PACKAGE "openmamba-repository release $SENDREPOSITORY $PACKAGE -d $REPOSITORYIMPORTTO $SIMULATEADD -y"
RET=$?
if [ ! "$SIMULATEADD" -a $RET -eq 0 ]; then
echo "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"released <b>$PACKAGE</b> from <b>$SENDREPOSITORY</b> to <b>$REPOSITORYIMPORTTO</b>\" STIME=`date +%s`" >> $STATEDIR/social_log
fi
;;
"repositorydiff")
$SUDO_WRAPPER local $PACKAGE "openmamba-repository diff $SENDREPOSITORY $PACKAGE -d $REPOSITORYIMPORTTO"
RET=$?
;;
"repositoryarchive")
[ "$REPOSITORYSIMULATE" = "true" -o ! "$USER_CANIMPORT" ] && SIMULATEADD="-s" || SIMULATEADD=
$SUDO_WRAPPER local $PACKAGE "openmamba-repository archive $SENDREPOSITORY $PACKAGE -y"
RET=$?
if [ ! "$SIMULATEADD" -a $RET -eq 0 ]; then
echo "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"archived <b>$PACKAGE</b> in <b>$SENDREPOSITORY</b>\" STIME=`date +%s`" >> $STATEDIR/social_log
fi
;;
"autoportnp") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "autoport -np $PACKAGE"; RET=$? ;;
"autoportlog") cat "$AUTOPORTLOGDIR/current.log"; RET=$? ;;
"repsearch") $SUDO_WRAPPER local "" "openmamba-repository search -i $REPSEARCHTEXT"; RET=$? ;;
"allowedgroups") $SUDO_WRAPPER $ENVIRONMENT "" "autospec --eval rpm_allowed_groups"; RET=$? ;;
"approvedlicenses") $SUDO_WRAPPER $ENVIRONMENT "" "autospec --eval rpm_approved_licenses | grep -v \"^#\"" | \
while read line; do
echo $line
done
RET=0
;;
"builddirfiles") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "cd @RPMBUILDDIR@ && find @BUILDDIR@"; RET=$? ;;
"configurehelp") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "cd @RPMBUILDDIR@/@BUILDDIR@ && ./configure --help"; RET=$? ;;
"showmacrosfile") $SUDO_WRAPPER $ENVIRONMENT $PACKAGE "cat /etc/rpm/macros.$MACROSFILE"; RET=$? ;;
*) RET=0 ;;
esac
if [ "$REQUEST" != "" ]; then
echo -n "<!-- ENDSCROLL --></pre>"
if [ $RET -eq 0 ]; then
echo "Result: <font color=green><b>OK</b></font>"
else
echo "Result: <font color=red><b>ERROR ($RET)</b></font>"
fi
echo -n "</div>"
echo -n "]]></output>"
fi
fi
#if [ ! "$REQUEST" -o "$REQUEST" = "output" ]; then
# echo -n "<output><![CDATA["
#
# echo "Show: [<a href=\"?NUM=\">All hosts</a>] [<a href=\"?SHOWLOG=monitor\">Build hosts monitor</a>]<br>"
# for h in `seq 0 ${#AUTOPORT_CGI_HOST[*]}`; do
# curl "${AUTOPORT_CGI_HOST[$h]}?AS_HOST=$h&SHOWINDEX=1" 2>/dev/null
# done
# echo "<hr>"
#
# [ "$HOST" = "$AS_HOST" ] && echo "<h2>Host: `hostname -s` (`uname -m`, kernel `uname -r`)</h2>"
#
# echo -n "]]></output>"
#fi
echo "</webbuild>"

266
webbuild/webbuild-checkpassword Executable file
View File

@ -0,0 +1,266 @@
#!/usr/bin/php
<?php
// Last sync [WP11537]
/**
* Portable PHP password hashing framework.
* @package phpass
* @since 2.5
* @version 0.1
* @link http://www.openwall.com/phpass/
*/
#
# Written by Solar Designer <solar at openwall.com> in 2004-2006 and placed in
# the public domain.
#
# There's absolutely no warranty.
#
# Please be sure to update the Version line if you edit this file in any way.
# It is suggested that you leave the main version number intact, but indicate
# your project name (after the slash) and add your own revision information.
#
# Please do not change the "private" password hashing method implemented in
# here, thereby making your hashes incompatible. However, if you must, please
# change the hash type identifier (the "$P$") to something different.
#
# Obviously, since this code is in the public domain, the above are not
# requirements (there can be none), but merely suggestions.
#
/**
* Portable PHP password hashing framework.
*
* @package phpass
* @version 0.1 / genuine
* @link http://www.openwall.com/phpass/
* @since 2.5
*/
class PasswordHash {
var $itoa64;
var $iteration_count_log2;
var $portable_hashes;
var $random_state;
function PasswordHash($iteration_count_log2, $portable_hashes)
{
$this->itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
if ($iteration_count_log2 < 4 || $iteration_count_log2 > 31)
$iteration_count_log2 = 8;
$this->iteration_count_log2 = $iteration_count_log2;
$this->portable_hashes = $portable_hashes;
$this->random_state = microtime() . (function_exists('getmypid') ? getmypid() : '') . uniqid(rand(), TRUE);
}
function get_random_bytes($count)
{
$output = '';
if (($fh = @fopen('/dev/urandom', 'rb'))) {
$output = fread($fh, $count);
fclose($fh);
}
if (strlen($output) < $count) {
$output = '';
for ($i = 0; $i < $count; $i += 16) {
$this->random_state =
md5(microtime() . $this->random_state);
$output .=
pack('H*', md5($this->random_state));
}
$output = substr($output, 0, $count);
}
return $output;
}
function encode64($input, $count)
{
$output = '';
$i = 0;
do {
$value = ord($input[$i++]);
$output .= $this->itoa64[$value & 0x3f];
if ($i < $count)
$value |= ord($input[$i]) << 8;
$output .= $this->itoa64[($value >> 6) & 0x3f];
if ($i++ >= $count)
break;
if ($i < $count)
$value |= ord($input[$i]) << 16;
$output .= $this->itoa64[($value >> 12) & 0x3f];
if ($i++ >= $count)
break;
$output .= $this->itoa64[($value >> 18) & 0x3f];
} while ($i < $count);
return $output;
}
function gensalt_private($input)
{
$output = '$P$';
$output .= $this->itoa64[min($this->iteration_count_log2 +
((PHP_VERSION >= '5') ? 5 : 3), 30)];
$output .= $this->encode64($input, 6);
return $output;
}
function crypt_private($password, $setting)
{
$output = '*0';
if (substr($setting, 0, 2) == $output)
$output = '*1';
if (substr($setting, 0, 3) != '$P$')
return $output;
$count_log2 = strpos($this->itoa64, $setting[3]);
if ($count_log2 < 7 || $count_log2 > 30)
return $output;
$count = 1 << $count_log2;
$salt = substr($setting, 4, 8);
if (strlen($salt) != 8)
return $output;
# We're kind of forced to use MD5 here since it's the only
# cryptographic primitive available in all versions of PHP
# currently in use. To implement our own low-level crypto
# in PHP would result in much worse performance and
# consequently in lower iteration counts and hashes that are
# quicker to crack (by non-PHP code).
if (PHP_VERSION >= '5') {
$hash = md5($salt . $password, TRUE);
do {
$hash = md5($hash . $password, TRUE);
} while (--$count);
} else {
$hash = pack('H*', md5($salt . $password));
do {
$hash = pack('H*', md5($hash . $password));
} while (--$count);
}
$output = substr($setting, 0, 12);
$output .= $this->encode64($hash, 16);
return $output;
}
function gensalt_extended($input)
{
$count_log2 = min($this->iteration_count_log2 + 8, 24);
# This should be odd to not reveal weak DES keys, and the
# maximum valid value is (2**24 - 1) which is odd anyway.
$count = (1 << $count_log2) - 1;
$output = '_';
$output .= $this->itoa64[$count & 0x3f];
$output .= $this->itoa64[($count >> 6) & 0x3f];
$output .= $this->itoa64[($count >> 12) & 0x3f];
$output .= $this->itoa64[($count >> 18) & 0x3f];
$output .= $this->encode64($input, 3);
return $output;
}
function gensalt_blowfish($input)
{
# This one needs to use a different order of characters and a
# different encoding scheme from the one in encode64() above.
# We care because the last character in our encoded string will
# only represent 2 bits. While two known implementations of
# bcrypt will happily accept and correct a salt string which
# has the 4 unused bits set to non-zero, we do not want to take
# chances and we also do not want to waste an additional byte
# of entropy.
$itoa64 = './ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
$output = '$2a$';
$output .= chr(ord('0') + $this->iteration_count_log2 / 10);
$output .= chr(ord('0') + $this->iteration_count_log2 % 10);
$output .= '$';
$i = 0;
do {
$c1 = ord($input[$i++]);
$output .= $itoa64[$c1 >> 2];
$c1 = ($c1 & 0x03) << 4;
if ($i >= 16) {
$output .= $itoa64[$c1];
break;
}
$c2 = ord($input[$i++]);
$c1 |= $c2 >> 4;
$output .= $itoa64[$c1];
$c1 = ($c2 & 0x0f) << 2;
$c2 = ord($input[$i++]);
$c1 |= $c2 >> 6;
$output .= $itoa64[$c1];
$output .= $itoa64[$c2 & 0x3f];
} while (1);
return $output;
}
function HashPassword($password)
{
$random = '';
if (CRYPT_BLOWFISH == 1 && !$this->portable_hashes) {
$random = $this->get_random_bytes(16);
$hash =
crypt($password, $this->gensalt_blowfish($random));
if (strlen($hash) == 60)
return $hash;
}
if (CRYPT_EXT_DES == 1 && !$this->portable_hashes) {
if (strlen($random) < 3)
$random = $this->get_random_bytes(3);
$hash =
crypt($password, $this->gensalt_extended($random));
if (strlen($hash) == 20)
return $hash;
}
if (strlen($random) < 6)
$random = $this->get_random_bytes(6);
$hash =
$this->crypt_private($password,
$this->gensalt_private($random));
if (strlen($hash) == 34)
return $hash;
# Returning '*' on error is safe here, but would _not_ be safe
# in a crypt(3)-like function used _both_ for generating new
# hashes and for validating passwords against existing hashes.
return '*';
}
function CheckPassword($password, $stored_hash)
{
$hash = $this->crypt_private($password, $stored_hash);
if ($hash[0] == '*')
$hash = crypt($password, $stored_hash);
return $hash == $stored_hash;
}
}
$wp_hasher = new PasswordHash(8, TRUE);
if ($wp_hasher->CheckPassword($argv[1], $argv[2]) == "1")
exit(0);
else
exit(1);

70
webbuild/webbuild-sudo Executable file
View File

@ -0,0 +1,70 @@
#!/bin/bash
. /etc/sysconfig/autoport
ENVIRONMENT=$1
PACKAGE=$2
COMMAND=$3
TMPFILE=$4
if [ "$ENVIRONMENT" = "local" ]; then
# echo "Command: $COMMAND"
$COMMAND 2>&1 | sed "s|<|\&lt;|g"
exit 0
fi
if [ "${AUTOPORT_CHROOT[$ENVIRONMENT]}" ]; then
ENVPREFIX="/var/autoport/${AUTOPORT_CHROOT[$ENVIRONMENT]}"
WORKINGHOME="/usr/src/"
SUCMDPREFIX="chroot $ENVPREFIX su -l ${AUTOPORT_CHROOT_USER[$ENVIRONMENT]} -c"
RPMBUILDROOT="/var/tmp/"
[ "$TMPFILE" ] && {
cp $TMPFILE /var/autoport/${AUTOPORT_CHROOT[$ENVIRONMENT]}/$TMPFILE
chmod 755 /var/autoport/${AUTOPORT_CHROOT[$ENVIRONMENT]}/$TMPFILE
}
elif [ "${AUTOPORT_NATIVE[$ENVIRONMENT]}" ]; then
ENVPREFIX=
WORKINGHOME=`getent passwd ${AUTOPORT_CHROOT_USER[$ENVIRONMENT]} | cut -d: -f6`
SUCMDPREFIX="su -l ${AUTOPORT_CHROOT_USER[$ENVIRONMENT]} -c"
else
ENVPREFIX=
WORKINGHOME="/var/autodist"
SUCMDPREFIX="su -l autodist -c"
RPMBUILDROOT="/var/tmp/autodist"
[ "$TMPFILE" ] && chown autodist $TMPFILE
fi
eval `$SUCMDPREFIX "autospec --eval=tmppath_dir|grep -v '^#'"`
RPMBUILDROOT=$tmppath_dir
SPECFILE=${ENVPREFIX}${WORKINGHOME}/RPM/SPECS/$PACKAGE.spec
if [ -r "$SPECFILE" ]; then
# _tmpfile=`mktemp`
# _errtmpfile=`mktemp`
# rpm -q --specfile $SPECFILE --specedit > ${_tmpfile} 2>${_errtmpfile}
# [ -s ${_errtmpfile} ] && {
# cat ${_errtmpfile}
# rm -f ${_tmpfile} ${_errtmpfile}
# exit 254
# }
# SPECVERSION=`grep ^Version: ${_tmpfile} | sed "s|Version:[[:space:]]*||"`
SPECVERSION=`grep -c1 ^Version: ${SPECFILE} | sed "s|Version:[[:space:]]*||"`
BUILDROOT=$PACKAGE-root
#`grep ^BuildRoot: ${_tmpfile} | sed "s|BuildRoot:[[:space:]]*||"`
# SPECSETUP=`grep %setup ${_tmpfile} | sed "s|.*-n ||"`
BUILDDIR=$PACKAGE-$SPECVERSION
fi
RPMBUILDDIR=${WORKINGHOME}/RPM/BUILD
COMMAND=`echo $COMMAND | sed "s|@BUILDDIR@|$BUILDDIR|g"`
COMMAND=`echo $COMMAND | sed "s|@BUILDROOT@|$BUILDROOT|g"`
COMMAND=`echo $COMMAND | sed "s|@RPMBUILDDIR@|$RPMBUILDDIR|g"`
COMMAND=`echo $COMMAND | sed "s|@RPMBUILDROOT@|$RPMBUILDROOT|g"`
rettmpfile=`$SUCMDPREFIX mktemp`
$SUCMDPREFIX ". /etc/profile;cd $WORKINGHOME/RPM/SPECS;$COMMAND;echo \$? > $rettmpfile" 2>&1 | sed "s|<|\&lt;|g"
RET=`cat $rettmpfile`
$SUCMDPREFIX "rm -f $rettmpfile"
echo "Command: $SUCMDPREFIX \"cd $WORKINGHOME/RPM/SPECS;$COMMAND\";RET=$RET" >&2
if [ "$TMPFILE" -a "${AUTOPORT_CHROOT[$ENVIRONMENT]}" ]; then
rm -f /var/autoport/${AUTOPORT_CHROOT[$ENVIRONMENT]}/$TMPFILE
fi
exit $RET

View File

@ -0,0 +1,2 @@
apache ALL = NOPASSWD: /usr/libexec/webbuild-sudo