• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/corennnnn


コミットメタ情報

リビジョン39a76e97a70b0bcaccf8dbc0e28c62ac06c5cbda (tree)
日時2013-06-16 17:06:07
作者Andy Ross <andy.ross@wind...>
コミッターChih-Wei Huang

ログメッセージ

Allow for overriding environment variables in export

Don't silently append duplicates, delete the older version. Also
increase the size limit, as the set of shell variables on my test
system is already at 28.

Change-Id: Id2373cc197662ae14fabad4de5e4516fe30d44cc
For: AXIA-2870
Signed-off-by: Andy Ross <andy.ross@windriver.com>

変更サマリ

差分

--- a/init/init.c
+++ b/init/init.c
@@ -100,14 +100,24 @@ static int have_console;
100100 static char *console_name = "/dev/console";
101101 static time_t process_needs_restart;
102102
103-static const char *ENV[32];
103+static const char *ENV[128];
104104
105105 /* add_environment - add "key=value" to the current environment */
106106 int add_environment(const char *key, const char *val)
107107 {
108- int n;
109-
110- for (n = 0; n < 31; n++) {
108+ unsigned int n, kesz;
109+ char keyeq[128];
110+ int max_vars = sizeof(ENV)/sizeof(ENV[0]) - 1; /* final null for execve */
111+
112+ snprintf(keyeq, sizeof(keyeq), "%s=", key);
113+ kesz = strlen(keyeq);
114+
115+ for (n = 0; n < max_vars; n++) {
116+ if (ENV[n] && strncmp(ENV[n], keyeq, kesz) == 0) {
117+ /* Override */
118+ free((char*)ENV[n]);
119+ ENV[n] = NULL;
120+ }
111121 if (!ENV[n]) {
112122 size_t len = strlen(key) + strlen(val) + 2;
113123 char *entry = malloc(len);