Revision 4c8b82e2 src/pool/PoolObjectSQL.cc

View differences:

src/pool/PoolObjectSQL.cc
172 172
int PoolObjectSQL::replace_template(
173 173
        const string& tmpl_str, bool keep_restricted, string& error)
174 174
{
175
    string ra;
176

  
175 177
    Template * old_tmpl = 0;
176 178
    Template * new_tmpl = get_new_template();
177 179

  
......
189 191

  
190 192
    if (obj_template != 0)
191 193
    {
194
        if ( keep_restricted &&  new_tmpl->check_restricted(ra, obj_template) )
195
        {
196
            error = "Tried to change restricted attribute: " + ra;
197

  
198
            delete new_tmpl;
199
            return -1;
200
        }
201

  
192 202
        old_tmpl = new Template(*obj_template);
193 203
    }
194

  
195
    if (keep_restricted && new_tmpl->has_restricted())
204
    else if ( keep_restricted && new_tmpl->check_restricted(ra) )
196 205
    {
197
        new_tmpl->remove_restricted();
206
        error = "Tried to set restricted attribute: " + ra;
198 207

  
199
        if (obj_template != 0)
200
        {
201
            obj_template->remove_all_except_restricted();
202

  
203
            new_tmpl->merge(obj_template);
204
        }
208
        delete new_tmpl;
209
        return -1;
205 210
    }
206 211

  
207 212
    delete obj_template;
......
257 262

  
258 263
    if ( obj_template != 0 )
259 264
    {
260
        old_tmpl = new Template(*obj_template);
261

  
262 265
        obj_template->merge(new_tmpl);
263 266

  
264 267
        delete new_tmpl;

Also available in: Unified diff