diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2007-12-02 11:48:42 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2007-12-02 11:48:42 +0800 |
commit | 6dbbad9a294b007ec184b689a601ed8077f4d50b (patch) | |
tree | da4b7f314fab1393ac9155e5736688cd65ba4a20 | |
parent | 7e4a04307041642b99dc92212d03ddf108c934c2 (diff) | |
download | pttbbs-6dbbad9a294b007ec184b689a601ed8077f4d50b.tar pttbbs-6dbbad9a294b007ec184b689a601ed8077f4d50b.tar.gz pttbbs-6dbbad9a294b007ec184b689a601ed8077f4d50b.tar.bz2 pttbbs-6dbbad9a294b007ec184b689a601ed8077f4d50b.tar.lz pttbbs-6dbbad9a294b007ec184b689a601ed8077f4d50b.tar.xz pttbbs-6dbbad9a294b007ec184b689a601ed8077f4d50b.tar.zst pttbbs-6dbbad9a294b007ec184b689a601ed8077f4d50b.zip |
- shell execute: safer (just commiting ptt2 local modification,
not sure who wrote this - thanks!)
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3607 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | mbbsd/kaede.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/mbbsd/kaede.c b/mbbsd/kaede.c index 3f284adb..6dd3f95c 100644 --- a/mbbsd/kaede.c +++ b/mbbsd/kaede.c @@ -89,10 +89,15 @@ Rename(const char *src, const char *dst) if (!strchr(src, ';') && !strchr(dst, ';')) // Ptt 防不正常指令 // XXX 這樣是不夠的 { - snprintf(buf, sizeof(buf), "/bin/mv %s %s", src, dst); - system(buf); + pid_t pid = fork(); + if (pid == 0) + execl("/bin/mv", "mv", "-f", src, dst, (char *)NULL); + else if (pid > 0) + waitpid(pid, NULL, 0); + else + return -1; } - return -1; + return 0; } int |