Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d54a51a

Browse files
committed
Updated the HTML manual for the MySQL UDF and consequently other files. Thanks Roland!
1 parent 69204af commit d54a51a

4 files changed

Lines changed: 229 additions & 37 deletions

File tree

extra/mysqludfsys/lib_mysqludf_sys/lib_mysqludf_sys.html

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,81 @@ <h1>lib_mysqludf_sys</h1>
2323
This library <code>lib_mysqludf_sys</code> contains a number of functions that allows one to interact with the operating system.
2424
</p>
2525
<ol>
26-
<li><a href="#sys_exec"><code>sys_exec</code></a> - executes an arbitrary command, and can thus be used to launch an external application.</li>
26+
<li><a href="#sys_eval"><code>sys_eval</code></a> - executes an arbitrary command, and returns it's output.</li>
27+
<li><a href="#sys_exec"><code>sys_exec</code></a> - executes an arbitrary command, and returns it's exit code.</li>
2728
<li><a href="#sys_get"><code>sys_get</code></a> - gets the value of an environment variable.</li>
2829
<li><a href="#sys_set"><code>sys_set</code></a> - create an environment variable, or update the value of an existing environment variable.</li>
2930
</ol>
3031
<p>
3132
Use <a href="#lib_mysqludf_sys_info"><code>lib_mysqludf_sys_info()</code></a> to obtain information about the currently installed version of <code>lib_mysqludf_sys</code>.
3233
</p>
3334

35+
36+
<a name="sys_eval"></a><h2>sys_eval</h2>
37+
<p>
38+
<code>sys_eval</code> takes one command string argument and executes it, returning its output.
39+
</p>
40+
<h3>Syntax</h3>
41+
<pre>sys_eval(<b>arg1</b>)</pre>
42+
<h3>Parameters and Return Values</h3>
43+
<dl>
44+
<dt><code><b>arg1</b></code></dt>
45+
<dd>
46+
A command string valid for the current operating system or execution environment.
47+
</dd>
48+
<dt>returns</dt>
49+
<dd>
50+
Whatever output the command pushed to the standard output stream.
51+
</dd>
52+
</dl>
53+
<h3>Installation</h3>
54+
<p>
55+
Place the shared library binary in an appropriate location.
56+
Log in to mysql as root or as another user with sufficient privileges, and select any database.
57+
Then, create the function using the following DDL statement:
58+
</p>
59+
<pre>
60+
CREATE FUNCTION sys_eval RETURNS STRING SONAME 'lib_mysqludf_sys.so';
61+
</pre>
62+
<p>
63+
The function will be globally available in all databases.
64+
</p>
65+
<p>
66+
The deinstall the function, run the following statement:
67+
</p>
68+
<pre>
69+
DROP FUNCTION sys_eval;
70+
</pre>
71+
<h3>Examples</h3>
72+
<p>
73+
None yet
74+
</p>
75+
<h3>A Note of Caution</h3>
76+
<p>
77+
Be very careful in deciding whether you need this function.
78+
UDFs are available to all database users - you cannot grant EXECUTE privileges for them.
79+
As the commandstring passed to <code>sys_exec</code> can do pretty much everything,
80+
exposing the function poses a very real security hazard.
81+
</p>
82+
<p>
83+
Even for a benign user, it is possible to accidentally do a lot of damage with it.
84+
The call will be executed with the privileges of the os user that runs MySQL,
85+
so it is entirely feasible to delete MySQL's data directory, or worse.
86+
</p>
87+
<p>
88+
The function is intended for specialized MySQL applications where one needs extended
89+
control over the operating system.
90+
Currently, we do not have UDF's for ftp, email and http,
91+
and this function can be used to implement such functionality in case it is really necessary
92+
(datawarehouse staging areas could be a case in example).
93+
</p>
94+
<p>
95+
You have been warned! If you don't see the hazard, please don't try to find it; just trust me on this.
96+
</p>
97+
<p>
98+
If you do decide to use this library in a production environment, make sure that only specific commands can be run and file access is limited by using <a href="http://www.novell.com/documentation/apparmor/index.html">AppArmor</a>.
99+
</p>
100+
34101
<a name="sys_exec"></a><h2>sys_exec</h2>
35102
<p>
36103
<code>sys_exec</code> takes one command string argument and executes it.
@@ -92,6 +159,9 @@ <h3>A Note of Caution</h3>
92159
<p>
93160
You have been warned! If you don't see the hazard, please don't try to find it; just trust me on this.
94161
</p>
162+
<p>
163+
If you do decide to use this library in a production environment, make sure that only specific commands can be run and file access is limited by using <a href="http://www.novell.com/documentation/apparmor/index.html">AppArmor</a>.
164+
</p>
95165
<a name="sys_get"></a><h2>sys_get</h2>
96166
<p>
97167
<code>sys_get</code> takes the name of an environment variable and returns the value of the variable.

extra/mysqludfsys/lib_mysqludf_sys/lib_mysqludf_sys.sql

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
/*
2-
lib_mysqludf_sys - a library with miscellaneous (operating) system level functions
3-
Copyright (C) 2007 Roland Bouman
4-
Copyright (C) 2008-2009 Roland Bouman and Bernardo Damele A. G.
5-
web: http://www.mysqludf.org/
6-
email: mysqludfs@gmail.com, [email protected]
7-
8-
This library is free software; you can redistribute it and/or
9-
modify it under the terms of the GNU Lesser General Public
10-
License as published by the Free Software Foundation; either
11-
version 2.1 of the License, or (at your option) any later version.
12-
13-
This library is distributed in the hope that it will be useful,
14-
but WITHOUT ANY WARRANTY; without even the implied warranty of
15-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16-
Lesser General Public License for more details.
17-
18-
You should have received a copy of the GNU Lesser General Public
19-
License along with this library; if not, write to the Free Software
20-
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1+
/*
2+
lib_mysqludf_sys - a library with miscellaneous (operating) system level functions
3+
Copyright (C) 2007 Roland Bouman
4+
Copyright (C) 2008-2009 Roland Bouman and Bernardo Damele A. G.
5+
web: http://www.mysqludf.org/
6+
email: roland.bouman@gmail.com, [email protected]
7+
8+
This library is free software; you can redistribute it and/or
9+
modify it under the terms of the GNU Lesser General Public
10+
License as published by the Free Software Foundation; either
11+
version 2.1 of the License, or (at your option) any later version.
12+
13+
This library is distributed in the hope that it will be useful,
14+
but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16+
Lesser General Public License for more details.
17+
18+
You should have received a copy of the GNU Lesser General Public
19+
License along with this library; if not, write to the Free Software
20+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2121
*/
2222

2323
DROP FUNCTION IF EXISTS lib_mysqludf_sys_info;

extra/mysqludfsys/lib_mysqludf_sys_0.0.3.patch

Lines changed: 138 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ diff -uN lib_mysqludf_sys_0.0.2/install.sh lib_mysqludf_sys/install.sh
4747
+fi
4848
Binary files lib_mysqludf_sys_0.0.2/lib_mysqludf_sys_0.0.2.tar.gz and lib_mysqludf_sys/lib_mysqludf_sys_0.0.2.tar.gz differ
4949
diff -uN lib_mysqludf_sys_0.0.2/lib_mysqludf_sys.c lib_mysqludf_sys/lib_mysqludf_sys.c
50-
--- lib_mysqludf_sys_0.0.2/lib_mysqludf_sys.c 2009-01-21 20:52:54.000000000 +0000
50+
--- lib_mysqludf_sys_0.0.2/lib_mysqludf_sys.c 2009-01-22 12:01:55.000000000 +0000
5151
+++ lib_mysqludf_sys/lib_mysqludf_sys.c 2009-01-21 00:06:13.000000000 +0000
5252
@@ -1,8 +1,9 @@
5353
/*
@@ -177,24 +177,146 @@ diff -uN lib_mysqludf_sys_0.0.2/lib_mysqludf_sys.c lib_mysqludf_sys/lib_mysqludf
177177
+
178178

179179
#endif /* HAVE_DLOPEN */
180+
diff -uN lib_mysqludf_sys_0.0.2/lib_mysqludf_sys.html lib_mysqludf_sys/lib_mysqludf_sys.html
181+
--- lib_mysqludf_sys_0.0.2/lib_mysqludf_sys.html 2009-01-22 12:01:55.000000000 +0000
182+
+++ lib_mysqludf_sys/lib_mysqludf_sys.html 2009-01-22 10:21:46.000000000 +0000
183+
@@ -23,7 +23,8 @@
184+
This library <code>lib_mysqludf_sys</code> contains a number of functions that allows one to interact with the operating system.
185+
</p>
186+
<ol>
187+
- <li><a href="#sys_exec"><code>sys_exec</code></a> - executes an arbitrary command, and can thus be used to launch an external application.</li>
188+
+ <li><a href="#sys_eval"><code>sys_eval</code></a> - executes an arbitrary command, and returns it's output.</li>
189+
+ <li><a href="#sys_exec"><code>sys_exec</code></a> - executes an arbitrary command, and returns it's exit code.</li>
190+
<li><a href="#sys_get"><code>sys_get</code></a> - gets the value of an environment variable.</li>
191+
<li><a href="#sys_set"><code>sys_set</code></a> - create an environment variable, or update the value of an existing environment variable.</li>
192+
</ol>
193+
@@ -31,6 +32,72 @@
194+
Use <a href="#lib_mysqludf_sys_info"><code>lib_mysqludf_sys_info()</code></a> to obtain information about the currently installed version of <code>lib_mysqludf_sys</code>.
195+
</p>
196+
197+
+
198+
+ <a name="sys_eval"></a><h2>sys_eval</h2>
199+
+ <p>
200+
+ <code>sys_eval</code> takes one command string argument and executes it, returning its output.
201+
+ </p>
202+
+ <h3>Syntax</h3>
203+
+<pre>sys_eval(<b>arg1</b>)</pre>
204+
+ <h3>Parameters and Return Values</h3>
205+
+ <dl>
206+
+ <dt><code><b>arg1</b></code></dt>
207+
+ <dd>
208+
+ A command string valid for the current operating system or execution environment.
209+
+ </dd>
210+
+ <dt>returns</dt>
211+
+ <dd>
212+
+ Whatever output the command pushed to the standard output stream.
213+
+ </dd>
214+
+ </dl>
215+
+ <h3>Installation</h3>
216+
+ <p>
217+
+ Place the shared library binary in an appropriate location.
218+
+ Log in to mysql as root or as another user with sufficient privileges, and select any database.
219+
+ Then, create the function using the following DDL statement:
220+
+ </p>
221+
+ <pre>
222+
+CREATE FUNCTION sys_eval RETURNS STRING SONAME 'lib_mysqludf_sys.so';
223+
+ </pre>
224+
+ <p>
225+
+ The function will be globally available in all databases.
226+
+ </p>
227+
+ <p>
228+
+ The deinstall the function, run the following statement:
229+
+ </p>
230+
+ <pre>
231+
+DROP FUNCTION sys_eval;
232+
+ </pre>
233+
+ <h3>Examples</h3>
234+
+ <p>
235+
+ None yet
236+
+ </p>
237+
+ <h3>A Note of Caution</h3>
238+
+ <p>
239+
+ Be very careful in deciding whether you need this function.
240+
+ UDFs are available to all database users - you cannot grant EXECUTE privileges for them.
241+
+ As the commandstring passed to <code>sys_exec</code> can do pretty much everything,
242+
+ exposing the function poses a very real security hazard.
243+
+ </p>
244+
+ <p>
245+
+ Even for a benign user, it is possible to accidentally do a lot of damage with it.
246+
+ The call will be executed with the privileges of the os user that runs MySQL,
247+
+ so it is entirely feasible to delete MySQL's data directory, or worse.
248+
+ </p>
249+
+ <p>
250+
+ The function is intended for specialized MySQL applications where one needs extended
251+
+ control over the operating system.
252+
+ Currently, we do not have UDF's for ftp, email and http,
253+
+ and this function can be used to implement such functionality in case it is really necessary
254+
+ (datawarehouse staging areas could be a case in example).
255+
+ </p>
256+
+ <p>
257+
+ You have been warned! If you don't see the hazard, please don't try to find it; just trust me on this.
258+
+ </p>
259+
+ <p>
260+
+ If you do decide to use this library in a production environment, make sure that only specific commands can be run and file access is limited by using <a href="http://www.novell.com/documentation/apparmor/index.html">AppArmor</a>.
261+
+ </p>
262+
+
263+
<a name="sys_exec"></a><h2>sys_exec</h2>
264+
<p>
265+
<code>sys_exec</code> takes one command string argument and executes it.
266+
@@ -92,6 +159,9 @@
267+
<p>
268+
You have been warned! If you don't see the hazard, please don't try to find it; just trust me on this.
269+
</p>
270+
+ <p>
271+
+ If you do decide to use this library in a production environment, make sure that only specific commands can be run and file access is limited by using <a href="http://www.novell.com/documentation/apparmor/index.html">AppArmor</a>.
272+
+ </p>
273+
<a name="sys_get"></a><h2>sys_get</h2>
274+
<p>
275+
<code>sys_get</code> takes the name of an environment variable and returns the value of the variable.
180276
Binary files lib_mysqludf_sys_0.0.2/lib_mysqludf_sys.so and lib_mysqludf_sys/lib_mysqludf_sys.so differ
181277
diff -uN lib_mysqludf_sys_0.0.2/lib_mysqludf_sys.sql lib_mysqludf_sys/lib_mysqludf_sys.sql
182-
--- lib_mysqludf_sys_0.0.2/lib_mysqludf_sys.sql 2009-01-21 20:52:54.000000000 +0000
183-
+++ lib_mysqludf_sys/lib_mysqludf_sys.sql 2009-01-21 00:51:00.000000000 +0000
184-
@@ -1,8 +1,9 @@
185-
/*
186-
lib_mysqludf_sys - a library with miscellaneous (operating) system level functions
187-
Copyright (C) 2007 Roland Bouman
278+
--- lib_mysqludf_sys_0.0.2/lib_mysqludf_sys.sql 2009-01-22 12:01:55.000000000 +0000
279+
+++ lib_mysqludf_sys/lib_mysqludf_sys.sql 2009-01-22 10:21:53.000000000 +0000
280+
@@ -1,30 +1,33 @@
281+
-/*
282+
- lib_mysqludf_sys - a library with miscellaneous (operating) system level functions
283+
- Copyright (C) 2007 Roland Bouman
188284
- web: http://www.xcdsql.org/MySQL/UDF/
189285
190-
+ Copyright (C) 2008-2009 Roland Bouman and Bernardo Damele A. G.
191-
+ web: http://www.mysqludf.org/
192-
193-
194-
This library is free software; you can redistribute it and/or
195-
modify it under the terms of the GNU Lesser General Public
196-
@@ -19,12 +20,14 @@
197-
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
286+
-
287+
- This library is free software; you can redistribute it and/or
288+
- modify it under the terms of the GNU Lesser General Public
289+
- License as published by the Free Software Foundation; either
290+
- version 2.1 of the License, or (at your option) any later version.
291+
-
292+
- This library is distributed in the hope that it will be useful,
293+
- but WITHOUT ANY WARRANTY; without even the implied warranty of
294+
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
295+
- Lesser General Public License for more details.
296+
-
297+
- You should have received a copy of the GNU Lesser General Public
298+
- License along with this library; if not, write to the Free Software
299+
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
300+
+/*
301+
+ lib_mysqludf_sys - a library with miscellaneous (operating) system level functions
302+
+ Copyright (C) 2007 Roland Bouman
303+
+ Copyright (C) 2008-2009 Roland Bouman and Bernardo Damele A. G.
304+
+ web: http://www.mysqludf.org/
305+
306+
+
307+
+ This library is free software; you can redistribute it and/or
308+
+ modify it under the terms of the GNU Lesser General Public
309+
+ License as published by the Free Software Foundation; either
310+
+ version 2.1 of the License, or (at your option) any later version.
311+
+
312+
+ This library is distributed in the hope that it will be useful,
313+
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
314+
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
315+
+ Lesser General Public License for more details.
316+
+
317+
+ You should have received a copy of the GNU Lesser General Public
318+
+ License along with this library; if not, write to the Free Software
319+
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
198320
*/
199321

200322
-drop function lib_mysqludf_sys_info;
@@ -217,7 +339,7 @@ diff -uN lib_mysqludf_sys_0.0.2/lib_mysqludf_sys.sql lib_mysqludf_sys/lib_mysqlu
217339
+CREATE FUNCTION sys_exec RETURNS int SONAME 'lib_mysqludf_sys.so';
218340
+CREATE FUNCTION sys_eval RETURNS string SONAME 'lib_mysqludf_sys.so';
219341
diff -uN lib_mysqludf_sys_0.0.2/Makefile lib_mysqludf_sys/Makefile
220-
--- lib_mysqludf_sys_0.0.2/Makefile 2009-01-21 20:52:54.000000000 +0000
342+
--- lib_mysqludf_sys_0.0.2/Makefile 2009-01-22 12:01:55.000000000 +0000
221343
+++ lib_mysqludf_sys/Makefile 2009-01-19 09:11:00.000000000 +0000
222344
@@ -1,6 +1,4 @@
223345
-linux: \
-2.71 KB
Binary file not shown.

0 commit comments

Comments
 (0)