| 1 |
<# |
| 2 |
# The FreeWRT Webinterface |
| 3 |
#- |
| 4 |
# Copyright © 2007 |
| 5 |
# Thorsten Glaser <tg@aurisp.de> |
| 6 |
# |
| 7 |
# Provided that these terms and disclaimer and all copyright notices |
| 8 |
# are retained or reproduced in an accompanying document, permission |
| 9 |
# is granted to deal in this work without restriction, including un- |
| 10 |
# limited rights to use, publicly perform, distribute, sell, modify, |
| 11 |
# merge, give away, or sublicence. |
| 12 |
# |
| 13 |
# Advertising materials mentioning features or use of this work must |
| 14 |
# display the following acknowledgement: |
| 15 |
# This product includes material provided by Thorsten Glaser. |
| 16 |
# |
| 17 |
# This work is provided "AS IS" and WITHOUT WARRANTY of any kind, to |
| 18 |
# the utmost extent permitted by applicable law, neither express nor |
| 19 |
# implied; without malicious intent or gross negligence. In no event |
| 20 |
# may a licensor, author or contributor be held liable for indirect, |
| 21 |
# direct, other damage, loss, or other issues arising in any way out |
| 22 |
# of dealing in the work, even if advised of the possibility of such |
| 23 |
# damage or existence of a defect, except proven that it results out |
| 24 |
# of said person's immediate fault when using the work as intended. |
| 25 |
#><%pre> |
| 26 |
#include "common.h" |
| 27 |
#include "c_exec.h" |
| 28 |
#include <stdio.h> |
| 29 |
|
| 30 |
__RCSID("$Id$"); |
| 31 |
</%pre> |
| 32 |
<%attr> |
| 33 |
index = "change <a href=\"davfs2/davfs2\">davfs2 account</a> data"; |
| 34 |
</%attr> |
| 35 |
<%args> |
| 36 |
servr; |
| 37 |
uname; |
| 38 |
passw; |
| 39 |
really; |
| 40 |
</%args> |
| 41 |
<%cpp> |
| 42 |
runComp2(header@fwwif, title, "davfs2 account data"); |
| 43 |
if (really == "yes" && servr != "") { |
| 44 |
FILE *f; |
| 45 |
|
| 46 |
if ((f = fopen("/etc/davfs2/secrets", "wb")) != NULL) { |
| 47 |
fprintf(f, "%s\t\"%s\"\t\"%s\"\n", |
| 48 |
servr.c_str(), uname.c_str(), passw.c_str()); |
| 49 |
fclose(f); |
| 50 |
} |
| 51 |
} |
| 52 |
char *result, *cp; |
| 53 |
int i; |
| 54 |
servr = ""; |
| 55 |
uname = ""; |
| 56 |
passw = ""; |
| 57 |
result = c_exec("/bin/mksh -c 'while read line; do" |
| 58 |
" line=${line%%#*};" |
| 59 |
" [[ $line = *([ ]) ]] && continue;" |
| 60 |
" set -A x $line;" |
| 61 |
" print -r -- \"${x[0]} ${x[1]} ${x[2]}\" | tr -d \\\";" |
| 62 |
" break;" |
| 63 |
"done </etc/davfs2/secrets'", &i); |
| 64 |
if (result && (cp = strchr(result, '\t'))) { |
| 65 |
*cp++ = '\0'; |
| 66 |
servr = result; |
| 67 |
if ((cp = strchr((result = cp), '\t'))) { |
| 68 |
if (*result == '"' && cp[-1] == '"') { |
| 69 |
result++; |
| 70 |
cp[-1] = '\0'; |
| 71 |
} |
| 72 |
*cp++ = '\0'; |
| 73 |
if (*cp == '"') { |
| 74 |
char *cp2; |
| 75 |
|
| 76 |
cp2 = cp + strlen(cp) - 1; |
| 77 |
if (*cp2 == '"') { |
| 78 |
cp++; |
| 79 |
*cp2 = '\0'; |
| 80 |
} |
| 81 |
} |
| 82 |
uname = result; |
| 83 |
passw = cp; |
| 84 |
} |
| 85 |
} |
| 86 |
</%cpp> |
| 87 |
<h1>Change davfs2 account data</h1> |
| 88 |
<form action="davfs2?really=yes" method="post"><table> |
| 89 |
<tr> |
| 90 |
<td>Server (complete URI)</td> |
| 91 |
<td><input type="text" name="servr" value="<$servr$>" /></td> |
| 92 |
</tr><tr> |
| 93 |
<td>Username</td> |
| 94 |
<td><input type="text" name="uname" value="<$uname$>" /></td> |
| 95 |
</tr><tr> |
| 96 |
<td>Password</td> |
| 97 |
<td><input type="text" name="passw" value="<$passw$>" /></td> |
| 98 |
</tr><tr> |
| 99 |
<td colspan="2"><input type="submit" /></td> |
| 100 |
</tr> |
| 101 |
</table></form> |
| 102 |
<& footer@fwwif> |