diff --git a/client/mysqltest.c b/client/mysqltest.c index a45984ffe02..d713c99ec62 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -32,7 +32,7 @@ Holyfoot */ -#define MTEST_VERSION "3.0" +#define MTEST_VERSION "3.1" #include #include @@ -1817,15 +1817,14 @@ void do_copy_file(struct st_command *command) command command handle DESCRIPTION - chmod + chmod Change file permission of - NOTE! Simplified version, only supports +r, -r, +w, -w */ void do_chmod_file(struct st_command *command) { - mode_t mode= 0; + ulong mode= 0; static DYNAMIC_STRING ds_mode; static DYNAMIC_STRING ds_file; const struct command_arg chmod_file_args[] = { @@ -1840,12 +1839,11 @@ void do_chmod_file(struct st_command *command) ' '); /* Parse what mode to set */ - if (ds_mode.length != 4) + if (ds_mode.length != 4 || + str2int(ds_mode.str, 8, 0, INT_MAX, &mode) == NullS) die("You must write a 4 digit octal number for mode"); - str2int(ds_mode.str, 8, 0, INT_MAX, (long*)&mode); - - DBUG_PRINT("info", ("chmod %o %s", mode, ds_file.str)); + DBUG_PRINT("info", ("chmod %o %s", (uint)mode, ds_file.str)); handle_command_error(command, chmod(ds_file.str, mode)); dynstr_free(&ds_mode); dynstr_free(&ds_file); diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result index a560b811cce..12a35fcf48b 100644 --- a/mysql-test/r/mysqltest.result +++ b/mysql-test/r/mysqltest.result @@ -516,7 +516,7 @@ mysqltest: At line 1: Missing required argument 'mode' to command 'chmod' mysqltest: At line 1: You must write a 4 digit octal number for mode mysqltest: At line 1: You must write a 4 digit octal number for mode mysqltest: At line 1: Missing required argument 'file' to command 'chmod' -mysqltest: At line 1: command "chmod" failed with error -1 +mysqltest: At line 1: You must write a 4 digit octal number for mode mysqltest: At line 1: You must write a 4 digit octal number for mode hello hello diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index e16c72d4e5e..c06d51d9d49 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -1560,6 +1560,7 @@ remove_file $MYSQLTEST_VARDIR/tmp/file1.tmp; --error 1 --exec echo "chmod 06789 from_file;" | $MYSQL_TEST 2>&1 + # ---------------------------------------------------------------------------- # test for perl # ----------------------------------------------------------------------------